-- 更新20200114:新版本的 #define 条目宏和新结果
这是另一个新手问题。 我正在尝试创建一个 #define 宏,可用于生成例程的条目以及它的 #pragma prolog(( 和 #pragma epilog((:
#pragma prolog(<entryname>," <prologasmstuff>")
#pragma epilog(<entryname>," <epilogasmstuff>")
functiontype entryname (<parameters>) {
我已经尝试了以下几种变体(这代表了今天的尝试(:
#define Entry(
EntryType
,EntryName
,EntryVariables
,PrologString
,EpilogString
)
_Pragma("prolog(EntryName," PrologString"")
_Pragma("epilog(Entryname," EpilogString"")
EntryType EntryName (EntryVariables) {
预处理器似乎无法完成这项工作。 宏通过以下方式调用
:Entry(void,wto,char * MsgArea," CKKIP31P"," CKKEP31P")
编译器打嗝如下:
68 |Entry(void,wto,char * MsgArea," CKKIP31P"," CKKEP31P") | 1005
68 +_Pragma("prolog(EntryName," PrologString"") _Pragma("epilog(Entryname," EpilogString"") void + 1005
68 +wto (char * MsgArea) { + 1005
69 | | 1006
编译器发出以下消息:
WARNING CCN3224 SSAF.METALC.C(TSTENTRY):68 Incorrect pragma ignored.
WARNING CCN3224 SSAF.METALC.C(TSTENTRY):68 Incorrect pragma ignored.
关于如何查看"已解决"#pragmas 是什么样子或它们有什么问题的任何想法?
谢谢 斯科特·费根
这可能会做你想做的事,试一试:
#define STRINGIZE(x) #x
#define Entry(
EntryType
,EntryName
,EntryVariables
,PrologString
,EpilogString
)
_Pragma( STRINGIZE( prolog(EntryName,PrologString) ));
_Pragma( STRINGIZE( epilog(EntryName,EpilogString) ));
EntryType EntryName( EntryVariables ) { }
Entry(void, wto, char * MsgArea, " CKKIP31P", " CKKIE31P")