D9024使得无法识别的源文件类型

时间:2013-06-09 17:45:08

标签: windows visual-studio makefile mingw

如果我使用MS cl:

在cmd行上运行此cmd
cl -c /W3 /Od ioapi.c

目标文件,ioapi.obj按预期创建。

但是,如果我使用此条目创建一个makefile:

ioapi.obj: ioapi.c
    cl -c /W3 /Od ioapi.c

cl cl之前有一个标签

然后运行make ioapi.obj然后我收到此错误:

make ioapi.obj
cl -c /W3 /Od ioapi.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9024 : unrecognized source file type 'C:/MinGW/msys/1.0/W3', object file assumed
cl : Command line warning D9027 : source file 'C:/MinGW/msys/1.0/W3' ignored
cl : Command line warning D9024 : unrecognized source file type 'C:/MinGW/msys/1.0/Od', object file assumed
cl : Command line warning D9027 : source file 'C:/MinGW/msys/1.0/Od' ignored

ioapi.c

cl : Command line warning D9024 : unrecognized source file type 'C:/MinGW/msys/1.0/W3', object file assumed

cl是MS VS 2008编译器。

我安装了minGW,版本是从6个月前开始的。

如果我运行make -n ioapi.c我会按预期报告:

cl -c /W3 /Od ioapi.c

我从Visual Studio 2008命令提示符运行cl.exe(其中VS2008 env变量已预先设置)。

为什么我会收到这个奇怪的错误以及如何修复它?

我确实想知道这是否是MS环境的问题。但即使我在运行make之前运行vcvars32.bat文件来设置MS环境也没什么区别。

我注意到如果我使用它:

ioapi.obj: ioapi.c
    cl -c ioapi.c

然后错误就消失了。但我确实需要传递编译器开关。

1 个答案:

答案 0 :(得分:2)

问题是make处理/ W3 / Od开关。由于/符号,似乎认为/ W3是文件的开头。所以为了防止这种情况,我改变了使用的开关 - 而不是/。例如-W3 -Od,它是MS编译器/链接器可接受的。

所以makefile中的变化是:

ioapi.obj: ioapi.c
    cl -c -W3 -Od ioapi.c