0

I'm working on a migration project. I need to convert ESQL/C files which have .ec extension into c file on gcc. I know that ESQL/C program will create a .c file. But How can I get that?

FYI : I'm working on IBM Informix server.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • Which database server? Informix or something else? (Note that the [tag:esql] is for Entity SQL (read the info) — it is not appropriate here.) – Jonathan Leffler May 22 '17 at 21:45
  • For an Informix `.ec` file compiled with the `esql` program (script), you can use `esql -e` to 'Preprocess only, no compilation or linking' (in sufficiently recent versions — I don't recall that option, but running just `esql` gives that information, amongst others. If you confirm Informix as the DBMS, I'll make an answer out of the information. – Jonathan Leffler May 22 '17 at 21:51
  • Yes. working with IBM informix server only. @JonathanLeffler –  May 22 '17 at 21:53
  • @emb-pro, which versions of Informix and esql/c are you using? – Joe R. Jun 05 '17 at 04:25

1 Answers1

3

TL;DR — For an Informix .ec file compiled with the esql program (script), you can use the -e option to 'Preprocess only, no compilation or linking'.

esql -e esqlcode.ec

This produces esqlcode.c from esqlcode.ec. (Ignore my previous comment about 'sufficiently recent'; you won't be using a version that isn't sufficiently recent — my memory is failing once more.)

The esql script traditionally left the intermediate .c file lying around. My ESQL/C make rules all remove the generated .c file as a separate post-compilation step:

.ec.o:
    ${ESQL} ${ESQLFLAGS} -c $*.ec
    ${RM_F} $*.c

with appropriate definitions of suffixes, macros, etc.

The esql command

Using the Informix esql compiler (script), you can run it with no options to get a help message like this (try not to be scared: there's actually the usages for two commands):

Usage: esql [-e] [-thread] [-glu] [esqlcargs] [-cc] [otherargs] [-o outfile]
            [-cp] [-onlycp] [-np] [-nup]
            [-libs] esqlfile.ec [othersrc.c...] [otherobj.o...] [-lyourlib...]

        -e         Preprocess only, no compilation or linking
        -thread    Multithread support
        -glu       Enable GLU (GLS for Unicode)
        -esqlcargs: esqlc arguments (-g, -G, -nln, -Ipathname, -nowarn, -V, -ansi,
                                    -xopen, -local, -log, -EDname, -EUname,
                                    -icheck
        -cc        Arguments after cc go to c compiler only
        otherargs: Other arguments are passed to cc
        -o         Next argument is program name
        -libs      Display the list of libraries used by esql at link time.
        -cp        Run C preprocessor before esqlc
        -onlycp    Run only the C preprocessor, no esqlc, compilation or linking
        -np        No protection of SQL keywords in SQL statements
        -nup       No unprotection of SQL keywords, forces -onlycp


Usage: esqlc [-thread] [-gG] [-nln] [-Ipathname] [-nowarn] [-V] [-ansi]
             [-static] [-xopen] [-local] [-log file] [-EDname[=val]] [-EUname]
             [-icheck] [-keepccomment] [-version] esqlfile.ec
         -thread     Multithread support
         -g          Number every line (debugging purposes)
         -G          No line number (debugging purposes; same as -nln)
         -nln        No line number (debugging purposes; same as -G)
         -Ipathname  Add pathname to include file search path
         -nowarn     Do not print warnings
         -static     Link with static libraries
         -keepccomment Allow C style comments in SQL statements.
         -version    Displays build and version information.
         -V          Print preprocessor version information
         -ansi       Perform ANSI checking
         -xopen      Perform XOPEN checking
         -local      Make cursor/statement ids local to the file
         -log file   Log error and warning messages in file
         -EDname     Define specified preprocessor name flag
          [=val]     and set it equal to 'val'
         -EUname     Undefine specified preprocessor name flag
         -icheck     Check for indicator variables

The usage for esqlc is for the 'real' preprocessor, $INFORMIXDIR/lib/esqlc. The usage for esql is for the esql script itself — which is what you are primarily using. The esqlcargs in the esql usage are the ones that are listed for esqlc — they're passed through by the script to the program.

This output is from ESQL/C 4.10 associated with Informix 12.10. I won't bore you with a history of the ESQL/C version numbers.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278