如何简单地将 ESQL/C 文件转换为 C 文件? (嵌入-SQL/C文件到C文件)?

How can I simply convert an ESQL/C file to a C file? (Embedded- SQL/C file to C file)?

我正在处理一个迁移项目。我需要将扩展​​名为 .ec 的 ESQL/C 文件转换为 gcc 上的 c 文件。我知道 ESQL/C 程序会创建一个 .c 文件。但是我怎样才能得到呢?

仅供参考:我正在使用 IBM Informix 服务器。

TL;DR — 对于使用 esql 程序(脚本)编译的 Informix .ec 文件,您可以使用 -e 'Preprocess only, no compilation or linking'.

选项
esql -e esqlcode.ec

这会从 esqlcode.ec 生成 esqlcode.c。 (忽略我之前关于 'sufficiently recent' 的评论;您不会使用不够新的版本——我的记忆又一次失败了。)

esql 脚本传统上留下中间 .c 文件。我的 ESQL/C make 规则全部删除生成的 .c 文件作为单独的 post-编译步骤:

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

对后缀、宏等进行适当的定义

esql命令

使用 Informix esql 编译器(脚本),您可以 运行 它没有任何选项来获得这样的帮助消息(不要害怕:实际上有两个命令的用法):

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

esqlc 的用法用于 'real' 预处理器,$INFORMIXDIR/lib/esqlcesql 的用法是针对 esql 脚本本身——这是您主要使用的。 esql 用法中的 esqlcargs 是为 esqlc 列出的用法 — 它们由脚本传递给程序。

此输出来自与 Informix 12.10 关联的 ESQL/C 4.10。我不会让您厌烦 ESQL/C 版本号的历史。