Page 1 of 1

PL/I equivalent of C's ifdef?

Posted: Tue Oct 17, 2017 8:10 pm
by peeterjoot
I see that PL/I has macros. For example:
%DCL RECSZ FIXED;
%RECSZ = 80;
%ACTIVATE RECSZ;
Does it also have a C like 'if defined' or ifdef like construct that I could use to conditionally compile code in two different ways?

Re: PL/I equivalent of C's ifdef?

Posted: Tue Oct 17, 2017 8:55 pm
by Robert Sample
Google pl/I conditional compilation for about 252,000 results. PL/SQL results won't help you but there are some hits on the first page of results for PL/I.

Re: PL/I equivalent of C's ifdef?

Posted: Thu Oct 19, 2017 11:50 pm
by peeterjoot
I see some examples of conditional compilation, such as:

https://supportline.microfocus.com/docu ... pfmcro.htm

%IF A = 'CONTROL_1'
%THEN %DO;
RES = B + F(X);
%END;
%ELSE %DO;
RES = B - F(X) + SQRT(X);
LST = F(X) + 1;
%END;

However, it isn't clear to me that there is any equivalent to C's '#if defined' in PL/I. If this is possible, I'd like to see an example of such a construct (how it is coded in the PL/I source and what the equivalent of -D would be in the compilation command).

Re: PL/I equivalent of C's ifdef?

Posted: Fri Oct 20, 2017 2:15 am
by Akatsukami
Again noting my lack of recent experience in C, I do not believe that there is any real equivalent to #ifdef in the PL/I preprocessor. For certain limited functionality you could use the %SYSPARM function and the %IF statement.