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

标签 c informix embedded-sql

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

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

最佳答案

TL;DR — 对于使用 esql 程序(脚本)编译的 Informix .ec 文件,您可以使用 -e 选项“仅预处理,无编译或链接”。

esql -e esqlcode.ec

这会从 esqlcode.ec 生成 esqlcode.c。 (忽略我之前关于“足够新”的评论;您不会使用不够新的版本——我的内存又一次失败了。)

esql 脚本通常会留下中间的 .c 文件。我的 ESQL/C make 规则都将生成的 .c 文件作为单独的编译后步骤删除:

.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 的用法是针对“真正的”预处理器,$INFORMIXDIR/lib/esqlcesql 的用法是针对 esql 脚本本身 — 这是您主要使用的脚本。 esql 用法中的 esqlcargs 是为 esqlc 列出的那些 — 它们由脚本传递给程序。

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

关于c - 如何简单地将 ESQL/C 文件转换为 C 文件? (嵌入式 SQL/C 文件到 C 文件)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44122472/

相关文章:

c - 如何用C语言制作不同类型的三角形?

在 Windows 7 上使用 Openoffice BASE 与 Informix 进行 JDBC/ODBC 连接。不会显示表列表

c++ - 将 Oracle DB 表的 ROWID 存储为字符数组

c++ - 需要帮助将 C 字符串从嵌入式 SQL 提取复制到单独结构中的另一个 C 字符串

c - 在不对数组进行排序的情况下查找中位数

c++ - 总的通用指针类型是什么?

java - 生成的查询包含架构和目录名称

c# - 使用 Context.SaveChanges 时出现异常

c - 描述符中的 SQLSET 数据类型

c - 仅从字符串中获取前 2 个字符