Man*_*lva 9 c++ one-definition-rule undefined-behavior c++11
按照书中的C++编程语言(Bjarne Stroustrup),在第15.2.3节(一个定义规则)第425页,我编写如下程序:
file1.cpp
struct S2 { int a; char b; };
Run Code Online (Sandbox Code Playgroud)
file2.cpp
struct S2 { int a; char bb; };
int main(){ return 0;}
Run Code Online (Sandbox Code Playgroud)
编译我试过下面的命令.
g++ -std=c++11 file1.cpp file2.cpp
Run Code Online (Sandbox Code Playgroud)
和
clang++ -std=c++11 file1.cpp file2.cpp
Run Code Online (Sandbox Code Playgroud)
这两个命令都生成可执行文件,没有任何错误或警告.但是按照书中这个例子应该给出错误.
| 归档时间: |
|
| 查看次数: |
684 次 |
| 最近记录: |