Re: preprocessor line directives
Date: Mon, 12 Oct 1992 07:47:37 GMT
Message-ID: <heijink.718876057_at_athena.research.ptt.nl>
jos_at_and.nl (Jos Horsmeier) writes:
>In article <900_at_unidoct.chemietechnik.uni-dortmund.de> pape_at_plato.chemietechnik.uni-dortmund.de (David Pape) writes:
>|I have a Pro*C (Oracle SQL) program that needs to be run through a preprocessor
>|before compilation. The problem is that the Pro*C precompiler doesn't put
>|#line directives in the resulting *.c file, something which I would like
>|to have. Has anyone written a shell script/awk/c program to do this?
>|
>|Specifically, all SQL statements start with:
>|
>|EXEC SQL blah blah blah; /* lets say were on line 25 of SQL_file */
>|
>|and I would like to have:
>|
>|#line 25 "SQL_file"
>|EXEC SQL blah blah blah;
>|
>|in the SQL_file.
>|
>|Any helpers out there??
>Maybe, if you stick a line like this:
>just before and just followiing the embedded SQL statements in your code
>and run the C preprocessor first, before running the SQL preprocessor
>(or precompiler?) I said `maybe,' because I don't know if all SQL
>statements are valid pp-tokens for the C preprocessor ...
This depends on the C preprocessor you use. You should be aware of a number of problems:
- PRO*C allows only a limited record length for input. Some C macros are expanded to very long lines.
- #define directives may interfere with SQL reserved words. The best known example is NULL.
I tried the trick with two different C preprocessors. gcc works fine in most cases, the VAX vcc preprocessor does not accept constructs like 'abcdef', which are used in SQL. It says that a character constant must consist of only one character.
There is one safe solution: write your own preprocessor to do all actions you want and nothing else.
Purchase of PRO*C 2.0 may also be a good choice, since it has a C
like proprocessor built in, but I have no
experience with this product.
>I hope this works, otherwise you have to do a lot of string fiddling
>yourself ...
>kind regards,
-- Rudolf J. Heijink phone : +31 70 332 5709 PTT Research POB 421 fax : +31 70 332 6477 2260 AK Leidchsendam E-Mail: R.J.Heijink_at_research.ptt.nl (internet) NetherlandsReceived on Mon Oct 12 1992 - 08:47:37 CET