Re: esql 7.20 problem
Posted in 1997
>From: Tom <rdorgan@worldnet.att.net>
>Date: Tue, 05 Aug 1997 08:06:50 -0600
>X-Informix-List-Id: <news.41230>
>
>I must be missing something here. I have been using esqlc with C++ for 6
>months now under 5.08 and Solaris. Now we are heading to 7.20. So, I
>begin porting my code. I need to remove the useful header files posted
>to the repository by J. Loeffler.
(1) With an umlaut over the 'o', that's how Leffler is normally spelt in
Germany, but my family's name was anglicized to Leffler a long time
ago. Somewhere around 1700, give or take...
(2) Why did you have to remove my headers? I still use them for 7.23. In
fact, back in May 1997, I updated them to add a new header, esql_720.h
to get around omissions in the headers distributed by Informix. I
thought I posted them to c.d.i at the time, but they haven't made it to
the IIUG archive yet (but I sent them to Walt earlier today).
Therefore I include the new versions at the end of this message.
(3) Even on post-6.0 ESQL/C, the esqlc.h headers provide support for C++,
and the esql++ script does too.
>No problem. I run esql against my .ec file, I move the .c file to .C. I
compile the file using the C++ compiler. I link using esql. I get
undefined routines in the informix c library.
Well, that's what the esql++ script is designed to avoid, of course.
>Whoops, looks like those have been declared with c (not C++) linkage.
>Better check the generated code. Well, what have we here, gratuitously
>added to the top of each and every generated file:
>#include <sqlhdr.h>
>#include <sqlca.h>
>< and some other cruft >
>
>Sweet. these files force c declarations down my throat.
Yes. ESQL/C 7.23 and earlier really does generate C code which is not
in the C subset of C++. And the headers are not in general C++ safe.
That's what esql++ does for you.
There will soon, I believe, be a release of ESQL/C which really handles
C++ code better. The headers will be inherently C++ safe, and the
esql script will handle .C, .cpp, .cxx files as C++ files, and .ecpp as
C++ source code with ESQL/C (note no ++) embedded in it.
>OK, well, I can sed that stuff out.
Yes, you can. So can esql++.
>Let's try compiling the hand-tweaked code and see
>what happens. Darn, now the dtime_t structure is undefined. Well, lets
>add the datetime include file and try it again. Arghh! that file
>declares the date time routines with c linkage (again). Now what? Do I
>have to build my own include files which not only declare the external
>routines with "C" linkage AND put in the data structures?
>Say it aint so......
>
>Here's an example:
Well, the example needs fixing by adding:
#include <stdio.h>
#include "esqlc.h"
>int main(void)
>{
> dtime_t dt;
> short t[3];
> $long Today;
>
> dtcurrent(&dt);
> rtoday(&Today);
> printf("Today = %d\\n",Today);
> t[0] = 5;
> t[1] = 29;
> t[2] = 1997;
> Today = -1;
> (void) rmdyjul(t,&Today);
> printf("yesterday = %d\\n",Today);
return(0);
>}
>To build:
>1) esql -e atest.ec
>2) mv atest.c atest.C
>3) gcc or (CC) -I$INFORMIXDIR/incl/esql -c datest.C
>4) esql datest.o
No: esql++ -DESQLC_VERSION=720 -o atest atest.ec
>and it dont work!!
It works:
$ INFORMIXC=g++ esql++ -I$HOME/inc -DESQLC_VERSION=723 -o atest atest.ec
$ ./atestToday = 35646
yesterday = 35578
$
>Please tell me what I have missed here, I couldnt find any online
>documentation about this. I refuse to go back to C, in fact I cant.
Don't; just use the tools provided to allow you to use ESQL/C and C++.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
PS: Warning I do not reply to messages with anti-spam in the return path.
TechInfo # 5563
Short Description:
Using ESQL/C with a C++ Compiler
Long Description:
From: johnl@informix.com (Jonathan Leffler)
Date: Tuesday 12th December 1995
Updated: Wednesday 7th May 1997
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, 5.0x and 7.2x
* An esql++ compiler
* A pair of patch files for modifying your 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 other versions of ESQL/C?
* If you are still using a pre-4.00 version of ESQL/C, the chances are
that the code which edits the 4.xx code will be useful. However, the
prototypes for the ESQL/C interface functions are not known and will
have to be determined by inspection of the generated code. Good luck!
It will probably be easier to upgrade to a later version.
* I haven't been able to test version 8.xx ESQL/C; it isn't available to
me. However, the indications are that it will need the same treatment
as the other post-5.00 implementations of ESQL/C.
* Testing with the version 9.10 ESQL/C compiler indicates that this
script is still necessary.
* Ideally, you won't need this script at all for post-9.xx versions. If
you are using some later version, you will need to revise the script so
that the case statement on $ESQLC_VERSION handles the new (presumably
4-digit) version number.
Which versions of ESQL/C are are known to work with this?
* The code has been tested against Informix-ESQL/C versions 4.12.UC1,
5.06.UC1, 6.00.UE1, 7.13.UC1, 7.22.UC2, 9.10.UC2 on a Sun Sparc 20
running Solaris 2.5.1 with both SUNWspro C++ SPARCompiler SC4.0.1 and
GNU G++ 2.7.2.2.
Are there any known bugs?
* Life will get very difficult if you pass arguments with quotes or
spaces in them to your compil