Eclipse precompile cobol-source with gcc not working
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?
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.
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
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:
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?
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?
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.
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 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: