开发者

Compiler definitions of source code linked to lib change lib?

开发者 https://www.devze.com 2023-02-12 01:12 出处:网络
I have file A.cpp that has targetlibs=Lib.lib on the sources file. Lib.cpp was compiled with C_defines=-DS开发者_开发百科omething, but A.cpp is compiled with C_defines=-DOther.

I have file A.cpp that has targetlibs=Lib.lib on the sources file. Lib.cpp was compiled with C_defines=-DS开发者_开发百科omething, but A.cpp is compiled with C_defines=-DOther. Lib.pp contains #ifdefs for -DSomething and -DOther.

What happens in this case? Is -DSomething kept or replaced by -DOther? Is -DOther ignored? Or both are kept? Thanks


Defines have an effect at compile time, so -DSomething is kept for the library code and -DOther for the program code. Be careful, if a header of Lib , eg Lib.h , is included in A.cpp,-DOther is used for the header code as well, since it is in the same compilation unit as A.cpp.

0

精彩评论

暂无评论...
验证码 换一张
取 消