相关疑难解决方法(0)

为什么这个程序被三个C++编译器错误地拒绝了?

编写我编写的C++程序时遇到一些困难.

这个程序非常简单,据我所知,它符合C++标准中规定的所有规则.我已经两次阅读整个ISO/IEC 14882:2003以确定.

该计划如下:

在此输入图像描述

这是我尝试使用Visual C++ 2010编译此程序时收到的输出:

c:\dev>cl /nologo helloworld.png
cl : Command line warning D9024 : unrecognized source file type 'helloworld.png', object file assumed
helloworld.png : fatal error LNK1107: invalid or corrupt file: cannot read at 0x5172
Run Code Online (Sandbox Code Playgroud)

沮丧,我尝试了g ++ 4.5.2,但同样无益:

c:\dev>g++ helloworld.png
helloworld.png: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

我认为Clang(版本3.0主干127530)必须工作,因为它的标准一致性受到高度赞扬.不幸的是,它甚至没有给我一个漂亮的,突出显示的错误消息:

c:\dev>clang++ helloworld.png
helloworld.png: file not recognized: File format not recognized
collect2: ld returned 1 exit status
clang++: error: linker (via gcc) command …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors clang visual-c++

469
推荐指数
30
解决办法
32万
查看次数

什么时候可以在#include指令中省略文件扩展名?

我正在玩gmock并注意到它包含这一行:

#include <tuple>
Run Code Online (Sandbox Code Playgroud)

我原以为是tuple.h.

什么时候可以排除扩展名,它是否赋予指令不同的含义?

c++ standards include c-preprocessor

44
推荐指数
5
解决办法
1万
查看次数