[cfe-dev] Unhelpful "fatal error: error reading file data"

Robert Purves listrp at gmail.com
Wed Jul 15 23:48:58 PDT 2009


On replacing gcc by clang in my custom build system, puzzling failures  
occurred with an unhelpful message:
fatal error: error reading file data
This turned out to be clang's response to an especially 'bad'  
precompiled header left behind by my build system (gcc has a feature,  
not needed in clang, whereby pch files of different architectures can  
be placed in a directory *.h.gch).

$ ls -1
test.c
test.h
$ echo "" > test.h.gch
$ clang -include test.h test.c
fatal error: 'test.h.gch' does not appear to be a precompiled header  
file
1 diagnostic generated.
$ rm test.h.gch
$ mkdir test.h.gch
$ clang -include test.h test.c
fatal error: error reading file data
1 diagnostic generated.

Clang's message for a bad *.h.gch file is excellent. Could the same  
message be emitted if it's a directory?

Robert P.




More information about the cfe-dev mailing list