1

-- 更新 20200114:#define Entry 宏和新结果的新版本

另一个新手问题在这里。我正在尝试创建一个#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 的样子或它们有什么问题的任何想法?

谢谢,斯科特·法根

4

1 回答 1

1

这可能会做你想要的,试一试:

#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")
于 2020-01-14T19:53:44.927 回答