Skip to main content

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

system ist redhat-linux, visual-cobol 4

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

Hello lennart.wegner,

Can you give us some background about what you are trying to accomplish? Are you trying to use compiler options that you have previously used at the command line, or in a build script? Are you trying to use Visual COBOL to compile a mixture of COBOL and C routines?

The Micro Focus COBOL preprocessor directive, P, can be used to specify a preprocessor that will operate on COBOL source code before it is processed by the COBOL compiler. This preprocessor must be written specifically to cooperate with the Micro Focus COBOL compiler. I am only familiar with "gcc" as a C compiler, not as a Micro Focus conforming COBOL preprocessor.

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

Hello Blair,
i have a lot of cobol-code, running on a mainframe bevore. the cobol-code has a lot of c-includes with cobol-code inside, such as

INPUT-OUTPUT SECTION.
FILE-CONTROL.
#include "I1VOR01"


therefore i have to use a c-precompile to get proper cobol-code. i like to use gcc with -E option (precompile only). this works fine on the command line:

#!/bin/bash
#set -x
P=TTMRK
rm -f $P.cob
gcc -E -P -x c -D _VERSION="'6040'" -I/home/max/workMax/marmInclude -o $P.cob $P.in

do you have suggestions for this problem?

regards

lennart

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

Thank you for the additional info. So, it sounds like you are used to invoking gcc as a first "step" to bring in portions of the COBOL source file. Then in a second step, you separately submit the resulting source file to the COBOL compiler.

I have a couple of ideas, but first, a few more questions. When your "include" files are brought in, is gcc doing any additional processing to the included files? Perhaps replacing strings of text in the files? Are there "nested" #include statements, where one of these included files might also contain #include statements? Or, is gcc just bringing in the #include files as-is?

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

Sorry, one more question. Is this a one-time conversion, where you would be able to modify the source files if necessary? Or, do you need to leave them as-is, so that they could also continue to work in the old environment where using gcc is required?

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

yes, there ist string replacing like
#define _VERSION '6040'
..
move _VERSION to picXXXX

furthermore then ist code like

#ifdef _zos
...
#else
..
#endif

where #define _zos ist only set at the mainframe-compile and not at unix



no nested includes

#ifdef
#else
#define

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

no, not a one-time conversion. the code has to run at different target-machines (mainframe,linux)

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

Thanks for your updates. I would suggest trying the option in the Visual COBOL for Eclipse IDE for a pre-build event, to get the COBOL source generated by gcc using a script.

You can do this by right-clicking on the Project, and selecting Properties. Then, navigate to Micro Focus->Build Configurations-> Events. On the Events pane, you can enter commands that are to be executed before (or after) the actual Build (COBOL compile) takes place. You might try entering a command in the "Pre-build event command line" field to invoke a script, which would run the gcc preprocessor against each program in the project.

the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

Thanks for the hint. I tried this already.
Can you tell me where to find the actual build-variables-names, such as program name, to pass it on to the script ?
The "event"-gcc-script has to start the precompile and write the output in a temp-file.
The temp-file has to be the new input file for the following compile-step.


the precompile-step   "P(gcc) -E -P -x c  -I/home/max/workMax/include ENDP"

gets always the error "COBCH0018S Preprocessor error on initialization"

Any idea, what went wrong?

The command or script that you enter into the pre-build event is executed before the build of the programs actually begins. I don't believe that there is any variable that would allow you pick up program names for your script. I was thinking you might be able to write a script that would loop through the .in files, and where they were newer than the equivalent .cob files, invoke gcc to generate a new .cob from the .in. This idea assumes that you would be editing the .in files, and never manually touch the .cob files. Because the COBOL builder automatically builds files with the .cob extension, the resulting files should get picked up and compiled by the normal build process. Please note that I have not tested this idea - you would need to test to confirm that it works for you.

Another option (aside from writing a script) would be to write your own Integrated Preprocessor, sometimes called a "stacked" preprocessor. This could probably be written to do what gcc is doing for you now. Once written and compiled, an Integrated Preprocessor can be specified within your Build Configuration on the "Additional Preprocessors" pane. Integrated Preprocessors have the ability to make changes to each line of source before the compiler "sees" it, as well as insert lines, remove lines, etc. Here is a link to information in the documentation about Integrated Preprocessors:

www.microfocus.com/.../GUID-006D4634-7E8B-4D85-A3BC-15B4965E33C0.html