Re: C++ and informix
Posted in 1997
>From: Chengteh Lee <clee@acustaf.com>
>Date: Thu, 23 Jan 1997 14:32:45 -0600
>X-Informix-List-Id: <news.32939>
>
>How to compile informix esql using C++ compiler?
>A demo of Makefile and simple C++ code will be
>very very helpful.
This is a semi-frequently asked question. The answer is 'Yes, you can'.
It isn't completely straight-forward, but it can be done.
I attach a document which discusses using ESQL/C and C++ which I
contributed to an internal repository (TechInfo #5563). It includes a
shell archive containing a shell script called esql++, a set of header
files for the prototypes for the pre-6.0 releases of ESQL/C (and some other
bits and pieces) which is used by esql++, and a pair of patch files which
should be usable with the (public domain, GNU) program patch to fix a
version 4.x or 5.x ESQL/C script into one which will work with C++ (and
esql++).
Before sending it to c.d.i, I updated it with the 'latest and greatest'
versions of all these files. The headers have been refined a bit, and so
has the esql++ script, and I redid the patch files to fix the places where
the debug flags are handled. I now need to update the internal repository!
Most of this stuff should already be available via the IIUG archives
(http://www.iiug.org) in one form or another, but I changed the header
files in December 1996, so it seems worth reposting this now.
If you run into problems, please let me know, and we'll see what can be
done to fix them. Note that this is not a perfect fix; ESQL/C only
understands C, not C++, and even then, it doesn't understand arguments
declared using prototype notation.
I also have another archive of questions about C++ and ESQL/C, with entries
dating back to 1990. It has a lot of replicated material in it (one reason
for not sending it now), but goes through some of the restrictions on
mixing C++ and ESQL/C. If requested sufficiently often, I'll post it too.
Yours super-fluently (but not, I trust, superfluously),
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
===========================================================================
TechInfo # 5563
Short Description:
Using ESQL/C with a C++ Compiler
Long Description:
From johnl@informix.com Tue Dec 12 21:29 EST 1995 (Jonathan Leffler)
Subject: Using ESQL/C with C++
One of the more common requests these days is:
How do I compile ESQL/C code for use with C++?
There have been a variety of answers, but not any one systematic answer.
Now there is what I believe is a definitive answer -- it's all in the
attached shell archive.
What do you get?
* Updated ESQL/C prototypes for 4.00, 4.1x and 5.0x
* An esql++ compiler
* A pair of patch files for modifying youe standard ESQL/C compiler
* A minimal test application.
* No documentation apart from this message!
What do you need to do?
* Unpack the shell archive.
* Place the esql* headers in either $INFORMIXDIR/incl (version 4)
or $INFORMIXDIR/incl/esql (version 5 or later)
* Place the esql++ script in $INFORMIXDIR/bin
* Decide which version of ESQL/C you are using and set the
ESQLC_VERSION environment variable to a value such as:
export ESQLC_VERSION=506 # 5.06.UC1
* Optionally modify esql++ to give the correct default value of
of ESQLC_VERSION.
* Decide which C++ compiler you use -- if it isn't CC, set:
export INFORMIXC=g++* Try compiling the test application:
esql++ -o testapp testmain.ec testsub.ec
* Run it against your local stores database -- it should say '2'.
What if you can't modify your INFORMIXDIR?
* Copy $INFORMIXDIR/bin/esql to somewhere where you can modify it
(eg /some/where/bin/esql)
* Patch it.
* Place the headers in another directory (eg /some/where/include).
* Modify esql++ so that:
-- arglist starts of with -I/some/where/include as one component
-- ESQL defaults to /some/where/bin/esql
What about version 8 or later ESQL/C?
* I haven't been able to test that; it isn't available to me either.
* With luck, you won't need this at all.
* Given the normal way things work, you will probably need to modify the
case to include 8 (or whatever) where it currently has 7[0-9][0-9].
Testing?
* Tested against Informix-ESQL/C versions 4.12.UC1, 5.03.UC1, 5.04.UC1,
5.05.UC1, 5.06.UC1, 6.00.UE1.
Bugs?
* Life will get very difficult if you routinely pass arguments with a
single single quote in them to your compiler:
esql++ -DOPENQUOTE="'" -DSOMMAT="string with blanks" thingy.ec
I do have a solution: it is another program called escape which
deals with precisely that sort of problem.
arglist="$arglist `escape $arg`"
But that requires some more source and isn't generally necessary.
Any problems? Better let me know. Especially if you've got a fix.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
: "@(#)shar.sh 1.9"
#! /bin/sh
#
# This is a shell archive.
# Remove everything above this line and run sh on the resulting file.
# If this archive is complete, you will see this message at the end:
# "All files extracted"
#
# Created: Fri Jan 24 12:37:26 PST 1997 by johnl at Informix Software Ltd.
# Files archived in this archive:
# esql++
# esql.v4.patch
# esql.v5.patch
# esql4_00.h
# esql4_10.h
# esql5_00.h
# esqlc.h
# esqllib.h
# testapp.h
# testmain.ec
# testsub.ec
#
#--------------------
if [ -f esql++ -a "$1" != "-c" ]
then echo shar: esql++ already exists
else
echo 'x - esql++ (3066 characters)'
sed -e 's/^X//' >esql++ <<'SHAR-EOF'
X: "@(#)esql++.sh 1.3 96/11/27"
X#
X# ESQL/C++ compiler script
X# For Informix-ESQL/C Versions 4.00, 4.1x, 5.0x, 6.0x, 7.1x or later
X
X#################################################################
X# Prerequisite (mandatory) change to installed esql script for
X# Version 4.00, 4.1x, 5.0x ESQL/C compiler scripts.
X# diff old.esql new.esql
X# < CC="cc"
X# --
X# > CC=${INFORMIXC:-"cc"}
X# Note that this is not sufficient if you are also using the -g,
X# -G or -nln options. You then need to find the lines which read
X# CC="cc -g" and change them to CC="${CC} -g", or some equivalent
X# but more complex change. The '-G' option is a confounded
X# nuisance if you are trying to create shared libraries on
X# SVR4-base Unix.
X#################################################################
X# Additional prerequisite for all versions of ESQL/C:
X# -- The esqlc.h header must be installed in:
X# * $INFORMIXDIR/incl/esql -- Version 5.00 or later
X# * $INFORMIXDIR/incl -- Version 4.1x or 4.00
X# Additional prerequisite for pre-6.00 versions of ESQL/C:
X# -- The esqllib.h, esql5_00.h, esql4_10.h, esql4_00.h headers
X# must all be installed in the same directory as esqlc.h is.
X#################################################################
X
X: ${ESQL:=esql}
X: ${ESQLC_VERSION:=600}
X
X# Some C++ compilers are