Re: Using Pro*C with C++

From: Mark Miller <mmille10_at_earthlink.net>
Date: 1998/11/24
Message-ID: <365B7EAF.17FE_at_earthlink.net>#1/1


Matt Roper wrote:
>
> I am writing replacements for some old programs at my company. These
> programs were written in C and used Pro*C to access an Oracle database.
> I am unfamiliar with Pro*C and haven't found any documentation on it yet.
> I would like to write my programs in C++ and use the Pro*C preprocessor,
> but I am not sure if this is possible. The code generated by Pro*C
> doesn't seem to compile under the C++ compiler I use, but it does compile
> under gcc if I don't use any C++-specific statements. Is there any way I
> can make Pro*C generate valid C++ code? Thanks for your help.
>
> ============================
> Matt Roper
> Tektronix, Inc.
> (503) 627-2023
> mattrope_at_mdhost.cse.tek.com

In my documentation it says you have to set the following options:

CODE=CPP
PARSE=PARTIAL (or NONE)
CPP_SUFFIX=cpp (or whatever suffix you want it to generate)

This is for the Unix version of Pro*C. If you are using the Windows version, look in the settings for the precompiler. You should be able to set each of these options in the settings dialog box. If not, try putting them in as command line arguments to the precompiler, if the settings screen will let you type in your own.

If you are using Unix, put all of the options on the precompiler command line.

Note: You cannot set PARSE to FULL if you are compiling C++ code, since that turns on all C code checks that the preprocessor does. I am not sure, but if you set it to PARTIAL, you may have to declare your bind variables, any types used in declaring them, and any constants used in EXEC SQL statements inside of DECLARE SECTION blocks, as in:

EXEC SQL BEGIN DECLARE SECTION;
typedef char a;
#define A_CONST 1
char a, b;
EXEC SQL END DECLARE SECTION; Don't quote me on it. Check your documentation.

In any case, you should be able to run your C++ compiler on the resulting code.

---Mark
mmiller_at_nyx.net Received on Tue Nov 24 1998 - 00:00:00 CET

Original text of this message