Charles,
it must be bug with the macro preprocessor used by USS's cc comand.
Even K&R's 1978 definition of C makes it clear that arguments inside "..." 
strings are not to be substituted.

An obvious workaround would be
#define V 5                                                            
#define STRINGZ(w,x,y,z) printf("%d %s %s %s %s\n", V, #w, #x, #y, #z)
but such a clear bug makes you wonder how many programs out there it has 
affected.
Then again, maybe everyone is using c89, c99, c++ or xlc for any important USS 
C programs.

-dap

________________________
On Mon, 1 Sep 2014 23:45:30 +0100, Andy Taylor <a...@purplemongoose.co.uk> 
wrote:
>Charles
>I compiled this on a 1.12 system under both batch and USS and results were as 
>expected.
>Preprocessor output under USS using a c89 -V gives:
>
>STRINGZ(The, quick, brown, fox);                              
>printf("%d %s %s %s %s\n", 5, "The", "quick", "brown", "fox");
> ...<snip>...
>Regards
>Andy T.
>
>
>On 1 Sep 2014, at 21:53, Charles Mills <charl...@mcn.org> wrote:
>
>> An associate is seeing very strange (apparent) C compiler behavior. z/OS
>> V2R1. I would be interested in feedback and comments.
>> 
>> Consider the following:
>> 
>> #define V 5                                                            
>> #define STRINGZ(a,b,c,d) printf("%d %s %s %s %s\n", V, #a, #b, #c, #d)
>> STRINGZ(The, quick, brown, fox);  /* macro invocation */
>> 
>> Here is what the compiler is making of it:
>> 
>> printf("%fox %s %s %s %s\n", 5, "The", "quick", "brown", "fox");
>> 
>> That is, it is apparently substituting parameter d, "fox", for the d
>> in the first printf() argument.
>> 
>> Neither the MS VS C compiler nor the gnu C compiler appear to behave this 
>> way.
>> 
>> I see the behavior only under USS with the cc command; not from an MVS batch
>> compile (although I have not yet figured out all of the variables).
>> 
>> Charles 
>> 

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to