GCC 4.3 related build problems: missing #include
In GCC 4.3 the C++ header dependencies have been cleaned up. In the past, compilation would often be quite slow because including a simple header would indirectly include a lot of other headers, even if they were not needed to compile the current code. Many headers have now been cleaned up with the result that compilation is quicker. The downside is that programmers cannot rely on indirect inclusion of headers they may need anymore. Instead, everything that is needed has to be directly referenced with an #include.
Typical errors look like these:
error: 'find' is not a member of 'std' error: 'exit' was not declared in this scope
Below is a table showing which header needs to be included for a number of common functions:
Functions and defines | Header |
find, for_each, sort | algorithm |
isalnum, toupper | cctype |
INT_MIN, RAND_MAX | climits |
printf | cstdio |
atoi, free, rand | cstdlib |
EXIT_FAILURE | cstdlib |
strcmp, memcpy | cstring |
auto_ptr | memory |
fd_set, mode_t | sys/types.h |
typeid | typeinfo |