以下代码片段在添加-pedantic和-Werror有点旧的编译器上生成编译错误。
#include <cstdint>
#include <iostream>
int add(int a, int b){
return a + b;
}; // <-- stray semicolon
int main (){
return 0;
}
Run Code Online (Sandbox Code Playgroud)
然而,较新的编译器版本不会发生这种情况。请在https://godbolt.org/z/KWeb8WTxz上找到 GCC( 10.x和11.x )和 Clang(5.x、6.x)的矩阵来演示差异。
我的问题有两个部分: