c-preprocessor

    1热度

    1回答

    我正在开发一个有多个插件的C++/Qt程序。 对于每个类我必须定义一个插件的界面,它看起来像这样: //my class class qwerty; //my interface class qwertyPlug : public QObject, myPlug { Q_OBJECT Q_INTERFACES(nPanPlug) Q_PLUGIN_METADATA(IID "org.

    10热度

    3回答

    if constexpr是在C++程序中摆脱预处理器的一大步。但是它只能在功能 - 就像这个例子: enum class OS { Linux, MacOs, MsWindows, Unknown }; #if defined(__APPLE__) constexpr OS os = OS::MacOs; #elif defined(__MING

    2热度

    1回答

    为什么不能正常工作(它无法断言...我不希望它执行)? #define OS_MACOSX 0 #if defined(OS_MACOSX) fructose_assert(1==2); #endif

    4热度

    1回答

    我有一个项目,我有大量的条件定义可以使跨平台开发变得更容易。不过,我有问题让Doxygen提取所有的定义,因为它只会挑选那些只发生评估的定义。 例如在下面的代码片段中,Doxygen将记录TARGET_X86_64,但不是TARGET_ARM64。 #if defined(_M_ARM64) || defined(__arm64__) || defined(__aarch64__) /** Bu

    5热度

    1回答

    我知道这是可能的东西转换成字符串宏是这样的: #define STRING(s) #s printf("%s", STRING(i am string)); 但它有可能反其道而行之? #define MyType(type) ??? MyType("uint16_t") myint = 100;

    1热度

    2回答

    解释本comment后, /***************** arrayImpl.c **************/ #include"list/list.h" #if defined(ARRAY) .... #endif 我./Computing/list/arrayImpl.c写#include"list/list.h"使用Computing/testList.c程序,her

    0热度

    1回答

    我正在学习gcc选项DDEBUG。 下面是我的测试简单的代码: #include <stdio.h> #include <stdlib.h> #ifdef DEBUG #define debug(msg) printf("Debug: %s\n", msg) #else #define debug(msg) #endif int main(int argc, c

    -5热度

    2回答

    #include <stdio.h> #define STR /*~~Complete this line~~*/ /* such that the output of the code is M = 10 N = 5 */ #define N 5 #define M 10 int main() { printf(STR(M)); printf("\n"); pri

    2热度

    1回答

    考虑下面的代码: #if 0 #foobar #endif 在这种情况下,预处理器不抱怨#foobar不是一个有效的预处理指令。它只是跳过该块,因为#if 0和代码编译罚款。 现在考虑下面的代码: #if 0 #if 1 #endif 在这种情况下,预处理器突然抱怨,有一个失踪#endif指令。这让我感到困惑,因为它表明,即使在#if 0的情况下,预处理器似乎也不完

    0热度

    1回答

    我遇到了一个问题,因为#define(显然)没有被看到,所以编译失败。查看错误的最简单方法是如果我可以轻松查看包含特定C++文件的头文件的确切顺序。特别奇怪的是,代码在XCode 7.2.1下编译正常,但在XCode 7.3下失败了。 有什么方法可以在源文件上调用C预处理器吗?这可能会有所帮助。