Greetings,
Yes, _Pragma can be used within #define, just need additional steps on String converting.
I created a testcase based on your attempt. It works during compiling.
Improvement can be made according to your requirement.
#define STR(x) #x
#define STRPROLOG(x,y) prolog(x,#y)
#define STREPILOG(x,y) epilog(x,#y)
#define Entry( \
EntryType \
,EntryName \
,PrologString \
,EpilogString \
) \
_Pragma(STR( STRPROLOG(EntryName,PrologString) )) \
_Pragma(STR( STREPILOG(EntryName,EpilogString) )) \
EntryType EntryName (){ \
return 1234;}
Entry(int,wto,P1111111,E2222222)
#pragma prolog(fun1,"P0000001")
#pragma epilog(fun1,"E0000002")
int fun1();
int fun1(){
return 1;
}
Please refer to C/C++ '# operator' for coverting String:
https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.4.0/com.ibm.zos.v2r4.cbclx01/num.htmAlso, compile option PROLOG and EPILOG may be used for your own prolog and epilog:
https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.4.0/com.ibm.zos.v2r4.cbcux01/prolog.htm------------------------------
He Huang
------------------------------
Original Message:
Sent: Tue January 14, 2020 02:30 PM
From: Scott Fagen
Subject: IBM z/OS Metal C - Can I create a #define macro that includes #pragma statements?
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") |
68 +_Pragma("prolog(EntryName,\" PrologString\"") _Pragma("epilog(Entryname,\" EpilogString\"") void \+
68 +wto (char * MsgArea) { +
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
------------------------------
Scott Fagen
scottf@21csw.com
------------------------------