Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么是-D编译器标志C++(CLAN,GNU,MSVC)_C++_Makefile_Clang_Gnu - Fatal编程技术网

什么是-D编译器标志C++(CLAN,GNU,MSVC)

什么是-D编译器标志C++(CLAN,GNU,MSVC),c++,makefile,clang,gnu,C++,Makefile,Clang,Gnu,好的,我假设-D前缀意味着定义后面跟它的变量名,但是我找不到关于编译器标志的makefile特性的任何文档 CXX=clang-DTHISISPREPROCESSORVARIABLE 因此,make进程中的-DTHISISPREPROCESSORVARIABLE将定义预处理器变量THISISPREPROCESSORVARIABLE,并将编译以下代码 #ifdef THISISPREPROCESSORVARIABLE std::cout << "this should exi

好的,我假设-D前缀意味着定义后面跟它的变量名,但是我找不到关于编译器标志的makefile特性的任何文档

CXX=clang-DTHISISPREPROCESSORVARIABLE

因此,make进程中的-DTHISISPREPROCESSORVARIABLE将定义预处理器变量THISISPREPROCESSORVARIABLE,并将编译以下代码

#ifdef THISISPREPROCESSORVARIABLE
     std::cout << "this should exist with the -D" << endl;
#endif
这是正确的假设吗?这似乎是可行的,只是有人能确认-D指的是define吗?有人有指向一些makefile文档的链接,可以填写所有这些命令定义吗, 和 ,都有这个标志的文档,默认情况下,Clang只使用GCC标志。我刚刚在用于windows的clang cl上找到了它,并且在linux上更清楚地找到了它

执行clang cl/?要查看受支持选项的列表,请执行以下操作: /D定义宏


观察到这些是编译器标志,与makefile无关,这就是为什么在makefile文档中找不到它的原因。这些标志可以放在makefile中,makefile会将它们传递给编译器,但它们不是makefiles的一部分。

这是正确的假设吗?是的。你用它做实验了吗?你有没有得到任何与你的假设不符的结果?这是一个编译器选项,而不是make选项。所以你应该看看编译器文档。谢谢,GCC链接正是我想要的!是的,看起来clang遵循的是所有相同的标准。@Danoli3:clang接受我尝试过的所有GCC标志,但它肯定会忽略其中的几个。此外,clang cl是一个windows命令行,仅适用于基于unix的系统的clang-help。@Danoli3:我还没有在/D上找到与clang-cl无关的clang文档。