本文介绍了#用空格定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to write define with spaces such as:

#define replace to replacement here

我想将replace to"替换为replacement here".

我想测试私有成员:

我确实写过

#define private public

但它不适用于 Qt 中的私有插槽

but it didn't work for private slots in Qt

所以我打算使用类似的东西

so my intend was to use something like

#define private slots: public slots:

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

anyway I have found another way to test slots and by the way I'm aware of that this is an ugly hack.

推荐答案

不,你不能

#define identifier something

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

what you define must be an identifier which cannot contain space. Nor can it contain hyphen, begin with a number, etc. you can define only an identifier

你写的会起作用

#define replace to replace here

但不是你所期望的.这一行定义了 replace 被替换为 to replacement here

but not as you expect. This line defined replace to be substituted with to replacement here

这篇关于#用空格定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 09:22