GCC versions/flags 和 FAM
GCC versions/flags and FAM
我正在尝试将我们的构建系统从 make
移植到 CMake
,但我遇到了一个令人惊讶的问题,该问题不是“Googleable”的
我们的代码是 C++ 11/14,使用 GCC6.2 编译良好,make
在调用 GCC 时应用无数开关,主要是迂腐的警告。我构建了一个 CMake
系统,可以毫无问题地编译 (GCC 6.3) 大部分代码,但由于以下原因,某些模块无法构建
flexible array member ‘blahblah’ not at end of ‘struct‘
撇开它出现在 C++ 代码中的原因不谈。为什么它在基于 make
的系统中编译? AFAIK,灵活数组不是 C++ 标准的一部分。 GCC 特定扩展?什么命令行开关控制 FAM 行为?如何让它像在原始 make
系统中那样编译?
以防有人需要编译代码片段
struct Foo
{
int _10;
double _20;
int a[];
};
struct Bar
{
Foo foo;
double _1;
int _2;
}
要添加更多上下文,cmake
文件
cmake_minimum_required(VERSION 3.9)
project(foo VERSION ${FOO_VERSION} DESCRIPTION "foo")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 99)
add_executable(foo foo.cpp foo_backup.cpp main.cpp)
set_target_properties(foo PROPERTIES VERSION ${PROJECT_VERSION})
target_include_directories(foo PUBLIC ${CMAKE_SOURCE_DIR}/lib/include ${CMAKE_SOURCE_DIR}/lib/include/bar)
How do I make it compile as it did in the original make system
恢复到 GCC 6.2。此 -pedantic
错误是在 GCC 6.3 中为 C++ 引入的。
见compilation with 6.2 and compilation with 6.3
禁用迂腐编译将消除错误,但会带来其他放松。
我正在尝试将我们的构建系统从 make
移植到 CMake
,但我遇到了一个令人惊讶的问题,该问题不是“Googleable”的
我们的代码是 C++ 11/14,使用 GCC6.2 编译良好,make
在调用 GCC 时应用无数开关,主要是迂腐的警告。我构建了一个 CMake
系统,可以毫无问题地编译 (GCC 6.3) 大部分代码,但由于以下原因,某些模块无法构建
flexible array member ‘blahblah’ not at end of ‘struct‘
撇开它出现在 C++ 代码中的原因不谈。为什么它在基于 make
的系统中编译? AFAIK,灵活数组不是 C++ 标准的一部分。 GCC 特定扩展?什么命令行开关控制 FAM 行为?如何让它像在原始 make
系统中那样编译?
以防有人需要编译代码片段
struct Foo
{
int _10;
double _20;
int a[];
};
struct Bar
{
Foo foo;
double _1;
int _2;
}
要添加更多上下文,cmake
文件
cmake_minimum_required(VERSION 3.9)
project(foo VERSION ${FOO_VERSION} DESCRIPTION "foo")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 99)
add_executable(foo foo.cpp foo_backup.cpp main.cpp)
set_target_properties(foo PROPERTIES VERSION ${PROJECT_VERSION})
target_include_directories(foo PUBLIC ${CMAKE_SOURCE_DIR}/lib/include ${CMAKE_SOURCE_DIR}/lib/include/bar)
How do I make it compile as it did in the original make system
恢复到 GCC 6.2。此 -pedantic
错误是在 GCC 6.3 中为 C++ 引入的。
见compilation with 6.2 and compilation with 6.3
禁用迂腐编译将消除错误,但会带来其他放松。