求助!MDK中,要怎么定义全局宏?

2019-07-20 11:21发布

比如我定义了:
#define A 2
怎么使这个宏在所有工程文件中生效?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
10条回答
aozima
1楼-- · 2019-07-20 11:41
FORMRL 发表于 2017-10-24 12:05
可是如果我要定义#define A 2 ,这样的话,要怎么写?我试过A=2,A:2,A 2,都不对

help里面有示例

Keil EC++ Compiler
Preprocessor Symbols
Define sets preprocessor symbols, which can be checked with #if, #ifdef and #ifndef. The defined names are case-sensitive. Optionally, each name can have a value. Define: Check, NoExtRam, X1=1+5 is identical to the following C preprocessor #define statements:
#define Check
#define NoExtRam
#define X1 1+5

Undefine clears previous Define assignments that are entered in the options dialog of a higher Target or Group level.

FORMRL
2楼-- · 2019-07-20 16:49
 精彩回答 2  元偷偷看……
taizonglai
3楼-- · 2019-07-20 21:14
 精彩回答 2  元偷偷看……
FORMRL
4楼-- · 2019-07-20 22:14
zuozhongkai 发表于 2017-10-24 10:12
头文件包涵啊

可是我工程有100多个文件都需要这个宏,这100多个文件全部都去添加这个头文件吗?
八度空间
5楼-- · 2019-07-21 01:05
 精彩回答 2  元偷偷看……
FORMRL
6楼-- · 2019-07-21 06:53
八度空间 发表于 2017-10-24 11:14
添加

100多文件都添加?有没有更好的办法……

一周热门 更多>