1

Hello everybody I'm programming on Visual C++ 6.0 IDE my problem is: I tried to define macros from the command line at first I did this: project->settings c++ command definitions and i entered this macro: -DHELLO="HELLO!" when I use it from my source code I entered:

#ifdef HELLO
HELLO;
#endif

Until this everything is OK.

But my problem is with macros those takes arguments, so how I set a macro with arguments and the second question is how to expand it from source code?

Any help is really appreciated. I spent a lot of time googling and searching, reading ebooks but this didn't help.

4

1 回答 1

1

看来是不可能了……

如果您查看 Microsoft 文档,该/D选项的构造如下:

/Dname[= | # [{string | number}] ]

由于似乎不可能添加括号,因此我无法使用此命令行选项创建类似函数的宏...


注意:我在 Visual Studio 上尝试过很奇怪,我的智能感知将其视为类似函数的宏,因此代码中没有可见错误(下面没有红线),但是当编译时我得到:

error C3861: 'MACRO_TEST': identifier not found 

使用 type 的定义:

/D"MACRO_TEST( tst )= tst" // or -D"MACRO_TEST( tst )= tst"
于 2013-08-12T11:42:58.577 回答