| An Introduction to GCC - for the GNU compilers gcc and g++ by Brian J. Gough, foreword by Richard M. Stallman Paperback (6"x9"), 144 pages ISBN 0954161793 RRP £12.95 ($19.95) "Answers common questions and provides many useful hints" --- Dr. Gerald Pfeifer (SUSE) -- Technical Editor Get a printed copy>>> |
13.1 Preprocessor error messages
No such file or directory-
This error occurs if GCC cannot find a requested file on its search
path. The file may have been specified on the command-line, or with a
preprocessor
#includestatement. Either the filename has been spelled incorrectly or the directory for the file needs to be added to the include path or link path. Example:#include <stdoi.h> /* incorrect */ int main (void) { printf ("Hello World!\n"); return 0; }The program above tries to include the non-existent file ‘stdoi.h’ giving the error ‘stdoi.h: No such file or directory’. The correct filename should be ‘stdio.h’. macro or '#include' recursion too deep#include nested too deeply-
This error occurs if the preprocessor encounters too many nested
‘#include’ directives. It is usually caused by two or more files
trying to include each other, leading to an infinite recursion.
Example:
/* foo.h */ #include "bar.h" ...
/* bar.h */ #include "foo.h" ...
The solution to this problem is to ensure that files do not mutually include each other, or to use "include guards" (see section 7.4.2 Providing your own templates for an example). invalid preprocessing directive #...-
This error indicates that the preprocessor encountered an unrecognized
#command. Example:#if FOO int x = 1; #elsif BAR /* should be #elif */ int x = 2; #else int x = 3; #endif
The preprocessor syntax requires#eliffor the "else if" condition in#ifblocks, rather than#elseif. In the example above an invalid directive error occurs at the incorrect usage#elseif, but only whenFOOis defined (otherwise the preprocessor ignores everything up to the#elsestatement). warning: This file includes at least one deprecated or antiquated header.-
This warning is generated for C++ programs which include old-style
library header files, such as ‘iostream.h’, instead of the modern
C++ library headers without the ‘.h’ extension. The old headers
import their functions into the top-level global namespace, instead of
using the
std::namespace. Note that old-style header files are still supported, so this message is only a warning and existing programs will continue to compile. The message is actually generated by a#warningdirective in the old header files, and not by the preprocessor itself. Example:#include <iostream.h> /* old style */ int main (void) { cout << "Hello World!\n"; return 0; }This program uses an old-style header file ‘iostream.h’. It could be updated to use#include <iostream>andstd::coutinstead.
| ISBN 0954161793 | An Introduction to GCC - for the GNU compilers gcc and g++ | See the print edition |