Difference between CPPFLAGS and CXXFLAGS in GNU Make

半城伤御伤魂 提交于 2019-11-26 12:20:05

问题


What\'s the difference between CPPFLAGS and CXXFLAGS in GNU Make?


回答1:


CPPFLAGS is supposed to be for flags for the C PreProcessor; CXXFLAGS is for flags for the C++ compiler.

The default rules in make (on my machine, at any rate) pass CPPFLAGS to just about everything, CFLAGS is only passed when compiling and linking C, and CXXFLAGS is only passed when compiling and linking C++.




回答2:


By default, CPPFLAGS will be given to the C preprocessor, while CXXFLAGS will be given to the C++ compiler.

The GNU Make Manual is a good resource for questions like this (see Implicit Variables).




回答3:


CPPFLAGS are for the C preprocessor, while CXXFLAGS are for the C++ compiler.

See here.




回答4:


By default, they're set to something.

In practice, you need to know what every single project does. Virtually no one uses those defaults built into make, and if you rely on, for example, CPPFLAGS meaning "flags to the C preprocessor" you'll find that the project you care about has used it to mean "flags to the C++ compiler" instead. And does the CFLAGS flag get passed to C++ compile lines? Sometimes. Not always. Etc, etc, etc.



来源:https://stackoverflow.com/questions/495598/difference-between-cppflags-and-cxxflags-in-gnu-make

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!