I think the preprocessor handles files one by one and I can’t figure out how to do it with includes, so I think it’s impossible, but it would be great to hear other’s thoughts.
I have in a.cpp:
#define A 1
and I want to use it from 2.cpp.
EDIT:
I cant modify first file. So for now i just have copied defines. But question still opened.
Defines inside a source file aren’t seen by other translation units. Implementation files are compiled separately.
You can either
extern const int A = 1;in an implementation file and declare it when you want to use itextern const int A;.Of these, I’d say the first option is possibly the worst you can use.