Re: Pro*C / C++ ??
From: Raphael mankin <raph_at_panache.demon.co.uk>
Date: Fri, 8 Jan 1993 20:09:07 +0000
Message-ID: <726523747snz_at_panache.demon.co.uk>
Date: Fri, 8 Jan 1993 20:09:07 +0000
Message-ID: <726523747snz_at_panache.demon.co.uk>
In article <145384_at_lll-winken.LLNL.GOV> hudek_at_polaris.llnl.gov writes:
><||>
>
>Question about Oracle's Pro*C precompiler:
>
>As I understand it and from a quick look at some output, this simply takes
>source code statements that start with a key phrase (EXEC SQL...) and
>translates them into C code and Oracle system calls.
>
>Given that, is there any reason why the output of Pro*C couldn't then be
>run through Sun's C++ compiler and produce good executables? (since the
>C++ compiler can obviously handle straight C code).
>
Yes you can embed SQL in C++. There are minor caveats.
- Function arguments and class members cannot be SQL variables (within a DECLARE SECTION).
- ProC does not understand // comments.
- ProC generates things like: struct sqlca sqlca; which causes a name conflict in C++. You have to run a ``sed'' script over the generated C++ to substitute some of the names.
- You will have to include in every module, probably in a header file, a whole raft of declarations of the form: extern "C" void sqlxyz(...); to link the Oracle library.
- You _may_ have trouble with the AT&T C++ compiler. It compiles and links fine, but with some versions the code hangs when you connect to the DB. g++ is OK, as are newer versions of AT&T.
- Be sure to have a DECLARE SECTION in file scope before any functions in
each file. This is true for C as well. Otherwise some things will be
declared in the wrong scope.
Raphael Mankin Nil taurus excretum