天天看点

在英特尔的编译器里如何设置编译输出信息

最近我在开发论坛上看到了几个有关如何处理编译信息的问题,为了方便大家,我在这里将相关的信息总结如下:

注释(Remarks)

注释信息通常报告一些普通的但是有时在C/C++里不常用的信息。除非你在编译选项里说明了 /W4选项,编译器一般不会显示打印出注释信息。注释信息也不会停止正在进行的编译和连接等工作。注释信息不影响任何文件的输出。下面是一些有代表性的注释信息:

在英特尔的编译器里如何设置编译输出信息

       function declared implicitly

在英特尔的编译器里如何设置编译输出信息

       函数被隐含地说明

在英特尔的编译器里如何设置编译输出信息

       type qualifiers are meaningless in this declaration

在英特尔的编译器里如何设置编译输出信息

       声明中的限定类型无意义

在英特尔的编译器里如何设置编译输出信息

       controlling expression is constant

在英特尔的编译器里如何设置编译输出信息

       控制类型表达式是一个常量

警告信息(Warnings)

警告信息报告那些在C/C++使用过程中语法正确但是使用可疑的信息。缺省情况下,编译器会显示警告信息。通过/w选项的设置,你可以禁止警告信息的显示。敬告信息不会停止编译和连接。敬告信息也不会停止正在进行的编译和连接等工作。敬告信息不影响任何文件的输出。下面是一些有代表性的警告信息:

在英特尔的编译器里如何设置编译输出信息

       declaration does not declare anything

在英特尔的编译器里如何设置编译输出信息

       声明没有声明任何事情

在英特尔的编译器里如何设置编译输出信息

       pointless comparison of unsigned integer with zero

在英特尔的编译器里如何设置编译输出信息

       无符号整型和零比较无意义

在英特尔的编译器里如何设置编译输出信息

       possible use of = where == was intended

在英特尔的编译器里如何设置编译输出信息

       在使用 == 的地方可能使用了 =

错误信息(Errors)

错误信息在C/C++的使用中报告句法或语法的错误。编译器总是显示错误信息。错误信息出现后编译器将停止包含错误的目标代码模块的编译和连接;但是编译器允许继续分析编译其他模块来侦测可能的错误。一些典型的错误信息有:

在英特尔的编译器里如何设置编译输出信息

       missing closing quote

在英特尔的编译器里如何设置编译输出信息

       结束引用丢失

在英特尔的编译器里如何设置编译输出信息

       expression must have arithmetic type

在英特尔的编译器里如何设置编译输出信息

       表达式必须要有运算类型

在英特尔的编译器里如何设置编译输出信息

       expected a ";"

在英特尔的编译器里如何设置编译输出信息

       期望一个”;”的表达

选项摘要(Option Summary)

下表显示了用来控制注释,警告和错误信息的编译选项:

选项Option 结果Result
/w; -w

Disables all warning messages

禁止所有警告信息的显示

/W0; -W0

Disables warnings; displays errors

禁止警告信息的显示;显示错误信息

/W1, /W2; -W1, -W2

Displays warnings and errors.

显示警告和错误信息

/W3; -W3

Displays remarks, warnings, and errors. This level is recommended for production purposes

显示注释,警告和错误信息。这级显示建议用于产品发布

/W4, /Wall; -W4, -Wall

Displays all level 3 (n=3) warnings plus informational warnings, which in most cases can be safely ignored.

显示所有级别(n=3)的警告和那些在多数情况下能被安全过滤的信息性警告信息

/W5; -W5

Displays all remarks, warnings, and errors. This setting produces the most diagnostic messages

显示所有注释,警告和错误信息。这组选项设置用来生成最多的诊断信息

/WL; -Wbrief

Display brief one-line diagnostics

显示摘要性的诊断信息

/Wcheck; -Wcheck

Enable more strict diagnostics

启动更加严格的诊断

/Werror-all; -Werror-all

Change all warnings and remarks to errors

将所有警告和注释信息作为错误信息处理

/WX; -Werror

Change all warnings to errors

将所有警告信息作为错误信息处理

另外,你也可以通过设置各种/Qdiag的编译选项来控制诊断信息的显示。这个编译选项可以设置众多的参数和选项值来灵活地控制所要显示的诊断信息和报告。下面罗列了一些最常用的参数。

选项Option 结果Result

/Qdiag-enable:list

-diag-enable list

Enables a diagnostic message or a group of messages

启动显示一个诊断信息或一组信息

/Qdiag-disable:list

-diag-disable list

Disables a diagnostic message or a group of messages

禁止显示一个诊断信息或一组信息

/Qdiag-warning:list

-diag-warning list

Tells the compiler to change diagnostics to warnings

通知编译器将诊断信息作为警告信息处理

/Qdiag-error:list

-diag-error list

Tells the compiler to change diagnostics to errors

通知编译器将诊断信息作为错误信息处理

/Qdiag-remark:list

-diag-remark list

Tells the compiler to change diagnostics to remarks (comments)

通知编译器将诊断信息作为注释信息处理

这里,list项可能是一个特定的诊断IDs,warn, remark, 或 error三个关键之中的一个,或是一个关键字,该关键字说明某一组信息(par, vec, sc, driver, thread, par, port-linux, sc, openmp)

下面列出了其他和诊断有关的编译选项:

选项Option 结果Result

/Qdiag-dump

-diag-dump

Tells the compiler to print all enabled diagnostic messages and stop compilation

通知编译器打印所有激活的诊断信息并停止编译

/Qdiag-file[:file]

-diag-file[=file]

Causes the results of diagnostic analysis to be output to a file

诊断信息的分析结果将被输出到一个文件里

/Qdiag-file-append[:file]

-diag-file-append[=file]

Causes the results of diagnostic analysis to be appended to a file

诊断信息的分析结果将被添加到一个文件里

/Qdiag-error-limit:n

-diag-error-limitn

Specifies the maximum number of errors allowed before compilation stops

说明在停止编译前,允许显示的最多错误信息

希望上述总结能对你的软件开发开来方便。

继续阅读