显然在 .c 文件中,visual studio 自动生成未识别符号的声明。我尝试在不包含 stdio.h 的情况下使用 printf(),以及调用一些随机的 asd() 函数,它编译时没有错误,只出现编译器假定 extern 返回 int 的警告。可以肯定的是,我编译了程序集输出,它确实有那些外部声明。当然链接不成功。
我的问题是,如何关闭这种自动生成未识别符号声明的功能?我有一些项目要做,它可能会把我搞砸。
最佳答案
这是编译器警告 C4013。
http://msdn.microsoft.com/en-us/library/d3ct4kz9.aspx
您可以使用/we 标志设置编译命令,将特定警告视为错误。
http://msdn.microsoft.com/en-us/library/thxezb7y.aspx
/we n Treats as an error the compiler warning that is specified in n. For example, /we4326 flags warning number C4326 as an error.
如果你想变得非常保守,你可以将所有警告都视为错误。许多团队/项目认为这是最佳实践。
/WX Treats all compiler warnings as errors. For a new project, it may be best to use /WX in all compilations; resolving all warnings will ensure the fewest possible hard-to-find code defects. The linker also has a /WX option. See /WX (Treat Linker Warnings as Errors) for more information.
关于c - VS2013 假设 .c 文件的未识别符号的外部声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25127131/