Shachar Shemesh
Fri, 10 Oct 2008 00:48:22 -0700
Hi all,I'm having trouble getting gcc to do pre-compiled headers. The instructions for doing it are at http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html.
Here's what I got: precomp.h:
#ifndef PRECOMP_H #define PRECOMP_H //#error Include twice #include <stdio.h> #endif
hello.c:
#include "precomp.h"
int main()
{
printf("Hello, world.\n");
return 0;
}
Here's what I do: $ gcc -x c -o precomp.h.gch -c precomp.h -g -Wall -O2 Uncomment the "error" line $ gcc -x c -o hello.o -c hello.c -g -Wall -O2 In file included from hello.c:1: precomp.h:4:2: error: #error Include twiceNow, here's the strange part, when I run the compile command through strace, strace shows:
20522 open("hello.gcda", O_RDWR) = -1 ENOENT (No such file or directory) 20522 stat64("precomp.h.gch", {st_mode=S_IFREG|0644, st_size=3056, ...}) = 020522 open("precomp.h.gch", O_RDONLY|O_NOCTTY) = 4 20522 fstat64(4, {st_mode=S_IFREG|0644, st_size=3056, ...}) = 020522 read(4, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\1\0\3\0\1\0\0\0"..., 24) = 2420522 close(4) = 0 20522 open("precomp.h", O_RDONLY|O_NOCTTY) = 4 20522 fstat64(4, {st_mode=S_IFREG|0644, st_size=86, ...}) = 0 20522 read(4, "#ifndef PRECOMP_H\n#define PRECOMP"..., 86) = 86 20522 close(4) = 0
So, to recap:
* My version of gcc DOES support precompiled headers.
* I am placing the precompiled headers file at the right location
* gcc DOES manage to find my precompiled header file when it
searches for it
* But it ignores it!
Now the gcc page does give a list of reasons why a precompiled header
might be ignored, by my test case does not appear to cover any of those
reasons. The header file is a simple one, no defines before the
precompiled header, exact same command line to both header and body
code, only one per file.
Anyone either understanding the man page or having an idea what I'm doing wrong is welcome to let me know.
Shachar ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]