#define with space

met*_*dos 11 c++ macros c-preprocessor

是否可以使用空格编写define,例如:

#define replace to replacement here
Run Code Online (Sandbox Code Playgroud)

我想用" 替换在这里 " 替换" 替换为 ".

编辑:

我想测试私人会员:

我写了

#define private public
Run Code Online (Sandbox Code Playgroud)

但它不适用于Qt的私人老虎机

所以我打算用类似的东西

#define private slots: public slots:
Run Code Online (Sandbox Code Playgroud)

无论如何,我已经找到了另一种测试插槽的方法,顺便说一下,我知道这是一个丑陋的黑客.

Arm*_*yan 10

不,你不能

#define identifier something

您定义的内容必须是 不能包含空格的标识符.它也不能包含连字符,以数字开头等,您只能定义一个标识符

你写的东西会起作用

#define replace to replacement here

但不像你期望的那样.该行定义replace为替换为to replacement here

心连心.


Mar*_*one 7

你可以做...

#define replace replacement
#define to here
Run Code Online (Sandbox Code Playgroud)

注意定义的意外副作用。#undef在他们完成工作后,您可能会想要他们。