Reputation: 109
-- Update 20200114: New version of #define Entry macro and new results
Another newbie sort of question here. I'm trying to create a #define macro that I can use to generate the entry to a routine along with it's #pragma prolog() and #pragma epilog():
#pragma prolog(<entryname>," <prologasmstuff>")
#pragma epilog(<entryname>," <epilogasmstuff>")
functiontype entryname (<parameters>) {
I've tried a couple of variations of the following (this represents today's attempt):
#define Entry( \
EntryType \
,EntryName \
,EntryVariables \
,PrologString \
,EpilogString \
) \
_Pragma("prolog(EntryName,\" PrologString\"") \
_Pragma("epilog(Entryname,\" EpilogString\"") \
EntryType EntryName (EntryVariables) {
The preprocessor doesn't seem to be able to make this work. The macro is invoked via:
Entry(void,wto,char * MsgArea," CKKIP31P"," CKKEP31P")
And the compiler burps up the following:
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
The compiler issues the following messages:
WARNING CCN3224 SSAF.METALC.C(TSTENTRY):68 Incorrect pragma ignored.
WARNING CCN3224 SSAF.METALC.C(TSTENTRY):68 Incorrect pragma ignored.
Any thoughts on how to see what the "resolved" #pragmas look like or what's wrong with them?
Thanks, Scott Fagen
Upvotes: 1
Views: 154
Reputation: 554
This may do what you want, give it a try:
#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")
Upvotes: 1