PL/I equivalent of C's ifdef?

HLASM for MVS. PL/I for MVS & Enterprise PL/I for z/OS.
Previous topicNext topic

Topic Author
peeterjoot
Registered Member
Posts: 15
Joined: Fri Mar 03, 2017 2:01 am

PL/I equivalent of C's ifdef?

Post by peeterjoot » Tue Oct 17, 2017 8:10 pm

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?



User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1331
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

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

Post by Robert Sample » Tue Oct 17, 2017 8:55 pm

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.




Topic Author
peeterjoot
Registered Member
Posts: 15
Joined: Fri Mar 03, 2017 2:01 am

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

Post by peeterjoot » Thu Oct 19, 2017 11:50 pm

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).



User avatar

Akatsukami
Global Moderator
Global Moderator
Posts: 119
Joined: Tue Oct 20, 2015 3:20 am
Location: Bloomington, IL

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

Post by Akatsukami » Fri Oct 20, 2017 2:15 am

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.


"I come to the conclusion that, men loving according to their own will and fearing according to that of the prince, a wise prince should establish himself on that which is in his own control and not in that of others." -- Niccolò Machiavelli

Previous topicNext topic

Return to “Assembler & PL/I.”