home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!paladin.american.edu!gatech!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!news.funet.fi!funic!nokia.fi!paatero
- From: paatero@tele.nokia.fi (Janne Paatero)
- Newsgroups: comp.databases.oracle
- Subject: Re: Pro*C / C++ ??
- Message-ID: <PAATERO.93Jan9184847@olorin.tele.nokia.fi>
- Date: 9 Jan 93 16:48:47 GMT
- References: <145384@lll-winken.LLNL.GOV>
- Sender: usenet@noknic.nokia.fi (USENET at noknic)
- Organization: Nokia Telecommunications Ltd.
- Lines: 126
- In-Reply-To: hudek@polaris.llnl.gov's message of 7 Jan 93 22:26:49 GMT
- Nntp-Posting-Host: olorin.tele.nokia.fi
-
-
- (I'm afraid that I have messed up with my previous posting. If not, my
- apologies.)
-
-
- Hello Netland and especially David Hudek,
-
- In article <145384@lll-winken.LLNL.GOV> David Hudek had questions
- about Oracle's Pro*C precompiler and C++.
-
- > 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).
-
- The most important experience of mine is: Yes, they can be integrated
- and the executables work. (At least in my case --- I've been using
- Oracle version 6, Pro*C precompiler version 1.3 and C++ version 2.1
- in HP risc boxes, Tandem S2 systems and MIPS risc machines.)
-
- > The only potential problem I can think of at the moment from a programming
- > standpoint is how function declarations are handled...
-
- This is true. The workaround that has to be done is to modify the
- prototypes of Oracle system calls. As very well known, Pro*C output
- has function declarations like
-
- extern void sqlxxx();
-
- The trick that changes these to be compliant with C++ is to change the
- declaration to varparam (three dots inside parenthesis) and typesafe C
- linkage. So the previous declaration should be modified to something
- like
-
- #ifdef __cplusplus
- extern "C" {
- #endif /* __cplusplus */
-
- extern void sqlxxx(...);
-
- #ifdef __cplusplus
- }
- #endif /* __cplusplus */
-
- The #ifdefs in the previous example are there to make the modified
- code also compliant with ANSI standard C.
-
- Luckily this workaround task can be easily automated. I'm using the
- following shell && nawk script which I hereby release to public,
- free of charge, with absolutely no warranty of any kind, under GNU
- general public licence.
-
- The script takes the precompiled file as argument, locates the Oracle
- system call prototypes and makes the modifications described above to
- them. The original file is saved with a suffix .old.
-
- Hope this helps,
-
- janne
-
- /******************************************************************************
- Janne Paatero * "Maybe a db wheenie in Nokia Telecommunications Oy"
- paatero@tele.nokia.fi * "but still speaking only for myself."
- paatero@ntc.nokia.com *
- ******************************************************************************/
-
- ---clipeti--clap---clipeti--clap---clipeti--clap---clipeti--clap---clipeti--
- #!/bin/sh
- #
- # A simple shell and nawk script to repair output of Pro*C precompiler of
- # Oracle Inc. to make it compliant with C++.
- #
- # Copyright (C) Janne Paatero, 1992.
- # You may use and redistribute this under GNU general public licence.
- #
-
- if [ $# -ne 1 ]
- then
- echo "You should give the name of the file to be repaired."
- exit 1
- fi
-
- awk 'BEGIN {
-
- # Set up global variables, types and parameters.
-
- first = 1
- last = 0
- }
-
- function beginToken() {
- printf("/*******************************************************/\n")
- printf("/*** Repaired for C++ by PCCrepair ***/\n")
- printf("/*** PCCrepair script by J.Paatero ***/\n")
- printf("/*******************************************************/\n")
- printf("#ifdef __cplusplus\n")
- printf("extern \"C\" {\n")
- printf("#endif /* __cplusplus */\n")
- }
-
- function endToken() {
- printf("#ifdef __cplusplus\n")
- printf("}\n")
- printf("#endif /* __cplusplus */\n")
- }
-
- {
- while ($1 == "extern" && $2 == "void" && $3 ~ /^sql/ && $3 ~ /\(\);$/){
- if (first) {
- first = 0
- last = 1
- beginToken()
- }
- sub(/\(\);$/, "(...);")
- print
- getline
- }
- if (last) {
- last = 0
- endToken()
- }
- print
- }' $1 >/tmp/PCCrepair.$$
- mv -f $1 $1.old
- cp /tmp/PCCrepair.$$ $1
- rm /tmp/PCCrepair.$$
- ---clipeti--clap---clipeti--clap---clipeti--clap---clipeti--clap---clipeti--
-