Dann Corbit wrote:Because GCC's optimizer had a pre-frontal lobotomy.
Other compilers do not suffer this defect.
One way around it (if you are determined to use GCC) is to have two separate projects for your program.
One project is nicely modularized (for debugging, etc.) and the other one does this:
/* file: cheesy_hack.c contains the following: */
#ifdef _MSC_VER
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <more_include_files_go_here.h>
#include <etc.h>
#include "file1.c"
#include "file2.c"
#include "....c"
#include "filen.c"
and compile that when you want a speed build.
Thanks.
Here's another. This is a label in my makefile which makes
an alternate version of the program from all the C files
strung together with the main header file removed.
As to whether this is an optimal implementation, I don't
know.
At least it preserves my ability to use modules for
debugging and monolithic for performance but not
have to leave GNU C.
Microsoft clearly makes great compilers, no question about it.
- Code: Select all
massive.exe: *.c *.h
rm -f massive1 massive2 massive3 massive.c
cat *.c > massive3
egrep -v '#include "main.h"' massive3 > massive2
echo '#include "main.h"' > massive1
cat massive1 massive2 > massive.c
gcc -O2 -DNDEBUG massive.c -o massive.exe
I remember seeing something like this in Crafty's
Makefile many years ago.
Stuart