作者LPH66 ((short)(-15074))
看板Programming
标题Re: gcc #define 问题
时间Mon Oct 26 05:35:26 2009
※ 引述《sorryChen (陈扬和)》之铭言:
: GCC preprocessor 中
: '#'符号有特别的意义 是将参数变成字串
: ex: #define STRINGLIZE(ivalue) #ivalue
: STRINGLIZE(1)会是 "1"
: '##'也有特别的意义 是将两个参数接在一起
: 我的问题是, 如何escape '#'这个符号呢?
: ex:
: #define __MYFLAG__ '#pragma OMP for'
: preprocessor 会把#当成特殊符号 要怎麽escape呢
: 我试过 #define __MYFLACG(a) a
: 然後再用 #pragma 填到a中 好像不行...不知道有没有高手知道正却的作法
这样的话倒不如使用类似这样的写法
#ifdef USEOMP
#pragma OMP for
#endif
然後编译时用 -D 定义符号即可打开...
--
'You've sort of made up for it tonight,' said Harry. 'Getting the
sword. Finishing the Horcrux. Saving my life.'
'That makes me sound a lot cooler then I was,' Ron mumbled.
'Stuff like that always sounds cooler then it really was,' said
Harry. 'I've been trying to tell you that for years.'
-- Harry Potter and the Deathly Hollows, P.308
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.30.84