从Microsoft使用CL.exe [英] Using CL.exe From Microsoft

查看:105
本文介绍了从Microsoft使用CL.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一种工具,可以在内部使用Microsoft CL.exe编译器在Iam上编写C代码来编译我的源文件.使用我的工具创建标头和.C源文件.例如,我已经使用工具创建了EXTRA.h和EXTRA.C,并且在编译过程中,我将.C文件通过一些编译器选项传递给了编译器,例如:: cl.exe/c/nologo/G3/Zl/W3/Ox/Oy-/Zp8/D_32bit/DTARGET32 EXTRA.c,其中CL.exe编译我的.c文件并可以正常工作,如果有的话,编译器也会引发错误,

但是,如果.h文件中存在某些错误,就像我错过了标头文件中的一些半冒号或不需要的关键字一样. CL.exe编译器始终仅对.c文件抛出错误.示例:EXTRA.h
dfdfdfdfgdfg
EXTRA.C
没错

在这种情况下,编译器将引发错误,如下所示:

EXTRA.c(21):错误C2054:预期``(''后跟``dfdfdfdfgdfg''

尽管Heaer文件(.h文件)中存在错误,但编译器表示引用.c文件时出现错误,请参见上述编译器消息.


I have developed a tool to write C code where Iam internally using Microsoft CL.exe compiler for compilation of my source file. Using my Tool I create header and .C source file. For example I have created EXTRA.h amd EXTRA.C using the Tool and for the compilation process I pass my .C file to the compiler with some compiler option as :: cl.exe /c /nologo /G3 /Zl /W3 /Ox /Oy- /Zp8 /D_32bit /DTARGET32 EXTRA.c where CL.exe compiles my .c file and works fine also compiler throws error if there is any,

But if there is some error in the .h file as If I missed some semi colon or undesired Keyword in the Header file. CL.exe Compiler always throws error with respect .c file only. Example : EXTRA.h
dfdfdfdfgdfg
EXTRA.C
No error.

In this case Compiler throws error as:

EXTRA.c(21) : error C2054: expected ''('' to follow ''dfdfdfdfgdfg''

Although error is there in the Heaer file (.h file ) but compiler says error refering to the .c file please see above mentioned compiler message.


Compiler doesn''t refer to error in .h file.

推荐答案

AFAIK,C编译器通常不报告头文件中的错误-它们被视为一部分C源代码的错误,并在包含头文件的行上报告错误.您无能为力:除非错误发生在#include行上(例如,extra.c中的第21行),如果您无法立即发现问题,则用实际的文件内容临时替换#include ,然后以这种方式查找错误.
AFAIK, C compilers generally don''t report errors in header files - they are taken as part of the C source and the error is reported on the line including the header file. There is nothing you can do: except when the error occurs on a #include line (line 21 in extra.c for your example) if you can''t spot the problem immediately, then temporarily replace the #include with the actual file content, and look for the error that way.


这篇关于从Microsoft使用CL.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆