Diff. b/w Compiler Option and Compiler Directing Statements



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Diff. b/w Compiler Option and Compiler Directing Statements

Postby nikesh_rai » Tue Oct 22, 2013 12:44 pm

Hi Guys,

What is the difference between compiler option and compiler directing statements. What I got from the manuals:

Compiler options affect the aspects of your program


A compiler-directing statement is a statement that causes the compiler to take a specific action during compilation.


I saw some examples of both compiler options and compiler directing statements and both seems to me almost same.
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Diff. b/w Compiler Option and Compiler Directing Stateme

Postby BillyBoyo » Tue Oct 22, 2013 1:43 pm

Show the exmamples then.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Diff. b/w Compiler Option and Compiler Directing Stateme

Postby nikesh_rai » Tue Oct 22, 2013 2:05 pm

Yeah.. here the examples are:

Compiler Directing Statements: COPY, EJECT, REPLACE etc
Compiler Options: CHAR, CURRENCY, DYNAM, SSRANGE, OPTION, TRUNC etc
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Diff. b/w Compiler Option and Compiler Directing Stateme

Postby Robert Sample » Tue Oct 22, 2013 3:21 pm

Compiler-directing statements are changing the compile (adding code with a COPY, skipping the output to the top of the next page with EJECT). Compiler options set the way the generated code works (for example, TRUNC indicates how a PIC S9(04) COMP variable handles 5-digit values).
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Diff. b/w Compiler Option and Compiler Directing Stateme

Postby enrico-sorichetti » Tue Oct 22, 2013 3:24 pm

from the starting post, the manual You are reading has the concept mangled
the examples You gave are a bit better

I would say that ( still rough approach ) ...
the directives affect the compiler behavior
the options affect the program ( the thing You are compiling ) behavior

but even given the above also IBM mixes up the concept
IIRC IBM calls XREF/MAP and friends options

the whole point is a bit philosophic anyway :mrgreen:

edited
seems that Robert an I posted the same concept at about the same time :D
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Diff. b/w Compiler Option and Compiler Directing Stateme

Postby BillyBoyo » Tue Oct 22, 2013 4:09 pm

It is a thin line in places, as enrico suggests.

Also note that for non-Mainframe COBOLs the nuances might be different.

Not all compiler options affect generated code. No compiler directives (in Mainframe COBOLS) affect the generation of code by the compiler (obviously something like COPY causes source to be included).

They are itemised separately. The meaning of "directive" or "option" is not very important - unless someone asks in an interview. Don't bother with an accurate but confusing-sounding answer for that, just say it doesn't matter what the difference is, the difference is not clearly defined, and you know how to use both of them :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Diff. b/w Compiler Option and Compiler Directing Stateme

Postby Robert Sample » Tue Oct 22, 2013 4:58 pm

enrico - GMTA?
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Diff. b/w Compiler Option and Compiler Directing Stateme

Postby nikesh_rai » Tue Oct 22, 2013 5:09 pm

Actually... I am still confused.. :)

I tried to find out how I can explain them, I went through some examples given in IBM manuals. What I concluded that Compiler Directing Statements just provide direction to the compiler to compile the program with different compiler options; and at the same time it can change the structure of the program as well at compilation time. See the examples below:

BASIS statement
This extended source program library statement provides a complete COBOL program as the source for a compilation. For rules of formation and processing, see the description of text-name for the COPY statement.

*CONTROL (*CBL) statement
This compiler-directing statement selectively suppresses or allows output to be produced. The names *CONTROL and *CBL are synonymous.

COPY statement
This library statement places prewritten text into a COBOL program. A user-defined word can be the same as a text-name or a library-name. The uniqueness of text-name and library-name is determined after the formation and conversion rules for a system-dependent name have been applied. If library-name is omitted, SYSLIB is assumed.

DELETE statement
This extended source library statement removes COBOL statements from the BASIS source program.

EJECT statement
This compiler-directing statement specifies that the next source statement is to be printed at the top of the next page.

ENTER statement
The compiler handles this statement as a comment.

INSERT statement
This library statement adds COBOL statements to the BASIS source program.

PROCESS (CBL) statement
This statement, which is placed before the IDENTIFICATION DIVISION header of an outermost program, indicates which compiler options are to be used during compilation of the program.

REPLACE statement
This statement is used to replace source program text.

SERVICE LABEL statement
This statement is generated by the CICS translator to indicate control flow, and should be used at the resume point for a call to CEE3SRP. It is not intended for general use.

SKIP1/2/3 statement
These statements indicate lines to be skipped in the source listing.

TITLE statement
This statement specifies that a title (header) should be printed at the top of each page of the source listing.

USE statement
The USE statement provides declaratives to specify these elements:
Error-handling procedures: EXCEPTION/ERROR
User label-handling procedures: LABEL
Debugging lines and sections: DEBUGGING


May be my conclusion is wrong, but the examples says the same thing.

Coming to the Compiler Options, it have nothing to do with structure of the program. It will just describe, how program should behave at run time. Some examples like:

ARITH: The maximum number of digit positions in the PICTURE clause for packed-decimal, zoned-decimal, and numeric-edited data items is 18 with COMPAT option and 31 with EXTEND option

CICS: The CICS compiler option enables the integrated CICS translator and allows specification of CICS suboptions. You must use the CICS option if your COBOL source program contains EXEC CICS statements and the program has not been processed by the separate CICS translator.

MAP: Use MAP to produce a listing of the items defined in the DATA DIVISION.

OPTIMIZE: Use OPTIMIZE to reduce the run time of your object program. Optimization might also reduce the amount of storage your object program uses. Optimizations performed include the propagation of constants and the elimination of computations whose results are never used. Because OPTIMIZE increases compile time and can change the order of statements in your program, you should not use it when debugging.
and lots more.

Please correct me if I am wrong
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Diff. b/w Compiler Option and Compiler Directing Stateme

Postby enrico-sorichetti » Tue Oct 22, 2013 5:21 pm

MAP: Use MAP to produce a listing of the items defined in the DATA DIVISION.

please explain how the above might influence the program behavior at run time :geek:

as I said before IBM manuals mix up the concept.
why would You want to waste time in categorizing these items ?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Diff. b/w Compiler Option and Compiler Directing Stateme

Postby nikesh_rai » Tue Oct 22, 2013 5:29 pm

Yes.. you are correct.. :?
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post