I ran into a weird situation. My understanding is that the order of include header files doesn't matter much if I have put #ifndef #define #endif flag to all .h files.
Old codes a.h
#ifndef A_H
#define A_H
blah blah blah
#endif
a.cc
#include "a.h"
blah blah blah
And above codes worked fine.
Now I added a new header b.h
b.h
#ifndef B_H
#define B_H
blah blah blah
#endif
new a.cc
#include "a.h"
#include "b.h"
blah blah blah
The above a.cc compiled OK. However if I change the a.cc to
new a.cc version 2
#include "b.h"
#include "a.h"
blah blah blah
compiled failed with error: expected unqualified-id before ‘-’ token.
Sorry I cannot reproduce the same error in a tiny example. The compile error resulted in a big project. And if I tested in a small example created like above. It compiled, but if I switch back to the project. The #include directive order does matter. I have no idea where this problem might occur. Any one can give me a clue would be much helpful. Thanks in advance
[Solved] I've solved the problem by myself. Yet I think there might be other people stuck with it too. The reason which caused the problem was like the following
in test.cc
const int var_undef = -1;
#define var_undef (-1)
It compiles, while if you swap these two lines
#define var_undef (-1)
const int var_undef = -1
It compiles with the error expected unqualified-id before ‘-’ token as I stated.