Understanding roles of CMake, make and GCC

CMake generates files for other build systems. These can be Makefiles, Ninja files or projects files for IDEs like Visual Studio or Eclipse. The build files contain calls to compilers like GCC, Clang, or cl.exe. If you have several compilers installed, you can choose one. All three parts are independent. The compiler, the build system …

Read more

How can I make this GCC warning an error?

I’m not sure what the correct warning is, but once you’ve found it, you can change its disposition with the following (using ‘format’ as the example): #pragma GCC diagnostic error “-Wformat” Or as strager points out: gcc -Werror=format … I’ve checked the gcc source for this and this specific warning cannot be disabled via command …

Read more

What’s the best g++ optimization level when building a debug target?

GCC 4.8 introduces a new optimization level: -Og for the best of both worlds. -Og Optimize debugging experience. -Og enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience. …

Read more

GCC #pragma to stop compilation

You probably want #error: $ cd /tmp $ g++ -Wall -DGoOn -o stopthis stopthis.cpp $ ./stopthis Hello, world $ g++ -Wall -o stopthis stopthis.cpp stopthis.cpp:7:6: error: #error I had enough File stopthis.cpp #include <iostream> int main(void) { std::cout << “Hello, world\n”; #ifndef GoOn #error I had enough #endif return 0; }

What are “nosys”, “nano”, “rdimon” terms when using ARM GCC?

Gcc uses specs-strings, which control which subprocesses to run and what parameters it shall pass to them. The behavior defined by the spec-strings can be overridden using spec-files, whose purpose and syntax is documented here: https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html Looking at these spec files in the lib folder of the gcc tool chain (e.g. /usr/lib/arm-none-eabi/lib) we can see …

Read more