<bdo id='iL7F5'></bdo><ul id='iL7F5'></ul>
    1. <small id='iL7F5'></small><noframes id='iL7F5'>

      <i id='iL7F5'><tr id='iL7F5'><dt id='iL7F5'><q id='iL7F5'><span id='iL7F5'><b id='iL7F5'><form id='iL7F5'><ins id='iL7F5'></ins><ul id='iL7F5'></ul><sub id='iL7F5'></sub></form><legend id='iL7F5'></legend><bdo id='iL7F5'><pre id='iL7F5'><center id='iL7F5'></center></pre></bdo></b><th id='iL7F5'></th></span></q></dt></tr></i><div id='iL7F5'><tfoot id='iL7F5'></tfoot><dl id='iL7F5'><fieldset id='iL7F5'></fieldset></dl></div>
      <legend id='iL7F5'><style id='iL7F5'><dir id='iL7F5'><q id='iL7F5'></q></dir></style></legend>
      <tfoot id='iL7F5'></tfoot>

    2. 如何找出 cl.exe 的内置宏

      时间:2023-10-06
      <legend id='Zv1P6'><style id='Zv1P6'><dir id='Zv1P6'><q id='Zv1P6'></q></dir></style></legend>

          <tfoot id='Zv1P6'></tfoot>

            • <bdo id='Zv1P6'></bdo><ul id='Zv1P6'></ul>

              • <small id='Zv1P6'></small><noframes id='Zv1P6'>

              • <i id='Zv1P6'><tr id='Zv1P6'><dt id='Zv1P6'><q id='Zv1P6'><span id='Zv1P6'><b id='Zv1P6'><form id='Zv1P6'><ins id='Zv1P6'></ins><ul id='Zv1P6'></ul><sub id='Zv1P6'></sub></form><legend id='Zv1P6'></legend><bdo id='Zv1P6'><pre id='Zv1P6'><center id='Zv1P6'></center></pre></bdo></b><th id='Zv1P6'></th></span></q></dt></tr></i><div id='Zv1P6'><tfoot id='Zv1P6'></tfoot><dl id='Zv1P6'><fieldset id='Zv1P6'></fieldset></dl></div>
                  <tbody id='Zv1P6'></tbody>

                本文介绍了如何找出 cl.exe 的内置宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                有谁知道我如何找出 cl.exe 的内置/预定义宏?例如对于 gcc,以下命令行将列出所有编译器的内置宏

                Does anyone know how could I find out which are cl.exe's builtin/predefined macros? For example for gcc the following command line will list all the compiler's builtin macros

                gcc -dM -E - </dev/null
                

                我对类似于 gcc 的询问实际编译器"的方式感兴趣.

                I'm interested in a way similar to gcc's that is "ask the actual compiler".

                谢谢

                推荐答案

                此方法确实相当于向编译器询问预定义宏的列表,但它使用未记录的功能并且仅提供部分列表.为了完整起见,我将其包含在此处.

                This method does amount to asking the compiler for the list of predefined macros, but it uses undocumented features and provides only a partial list. I include it here for completeness.

                Microsoft C/C++ 编译器允许使用/B1 和/Bx 命令行开关分别为 .c 和 .cpp 文件调用替代编译器前端.命令行界面模块 CL.exe 通过 MSC_CMD_FLAGS 环境变量将选项列表传递给替换编译器前端.此选项列表包括一些预定义宏的 -D 宏定义.

                The Microsoft C/C++ compiler allows an alternative compiler front-end to be invoked using the /B1 and /Bx command line switches for .c and .cpp files respectively. The command-line interface module CL.exe passes a list of options to the replacement compiler front-end via the MSC_CMD_FLAGS environment variable. This list of options includes -D macro definitions for some of the predefined macros.

                以下简单的替换编译器前端打印出传递给它的选项列表:

                The following trivial replacement compiler front-end prints out the list of options passed to it:

                /* MyC1.c */
                
                #include <stdio.h>
                #include <stdlib.h>
                
                int main(void)
                {
                    char *p;
                
                    if ((p = getenv("MSC_CMD_FLAGS")) != NULL)
                        printf("MSC_CMD_FLAGS:
                %s
                ", p);
                
                    if ((p = getenv("MSC_IDE_FLAGS")) != NULL)
                        printf("MSC_IDE_FLAGS:
                %s
                ", p);
                
                    return EXIT_FAILURE;
                }
                

                将其编译为名为MyC1.exe"的可执行文件,确保它在 PATH 中可见,并告诉 CL.exe 使用以下方法之一将其作为编译器前端调用:

                Compile this to an executable named, for example, "MyC1.exe", ensure it is visible in the PATH and tell CL.exe to invoke it as the compiler front-end using one of the following:

                cl /B1MyC1.exe AnyNameHere.c  
                cl /BxMyC1.exe AnyNameHere.cpp  
                

                根据需要包括其他命令行选项,以查看为该组选项预定义了哪些宏.

                Include other command-line options as required to see which macros are predefined for that set of options.

                在结果输出中查找 -D 选项.下面给出了一个示例列表.在实际输出中,列表将以空格分隔,每个宏定义都以 -D 开头,并且还存在其他选项.

                In the resulting output look for the -D options. An example list is given below. In the actual output the list will be space-separated, with each macro definition preceded by -D, and other options also present.

                _MSC_EXTENSIONS  
                _INTEGRAL_MAX_BITS=64  
                _MSC_VER=1600  
                _MSC_FULL_VER=160030319  
                _MSC_BUILD=1  
                _WIN32  
                _M_IX86=600  
                _M_IX86_FP=0  
                _MT  
                

                此技术似乎包括大多数依赖于命令行选项的宏,但不包括那些始终定义的宏,例如 __FILE__ 和 __DATE__.

                This technique seems to include most macros that depend on command-line options, but excludes those that are always defined such as __FILE__ and __DATE__.

                这篇关于如何找出 cl.exe 的内置宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:在进程外使用 MiniDumpWriteDump 时如何获取异常信息 下一篇:如何指定 vc11 lambda 调用约定

                相关文章

                最新文章

                1. <i id='mR7rW'><tr id='mR7rW'><dt id='mR7rW'><q id='mR7rW'><span id='mR7rW'><b id='mR7rW'><form id='mR7rW'><ins id='mR7rW'></ins><ul id='mR7rW'></ul><sub id='mR7rW'></sub></form><legend id='mR7rW'></legend><bdo id='mR7rW'><pre id='mR7rW'><center id='mR7rW'></center></pre></bdo></b><th id='mR7rW'></th></span></q></dt></tr></i><div id='mR7rW'><tfoot id='mR7rW'></tfoot><dl id='mR7rW'><fieldset id='mR7rW'></fieldset></dl></div>

                2. <legend id='mR7rW'><style id='mR7rW'><dir id='mR7rW'><q id='mR7rW'></q></dir></style></legend>
                3. <small id='mR7rW'></small><noframes id='mR7rW'>

                  <tfoot id='mR7rW'></tfoot>

                    <bdo id='mR7rW'></bdo><ul id='mR7rW'></ul>