504 questions
Advice
0 votes
2 replies
85 views
Utilizing GSL for Intel C++ on Windows without implementing lib flags or pragma or CMake
Using vcpkg on Windows 11, I installed GSL (GNU Scientific Library) with vcpkg install gsl. Then I did set INCLUDE=E:\<mypath>\vcpkg\installed\x64-windows\include;%INCLUDE% set LIB=E:\<mypath&...
1 vote
1 answer
68 views
Gcc flag repetition of -Wl what does the linker actually do
I am currently working with a project that generates its compiler- and linkerflags by reading a configuration file. The resulting linker-flags of interest are: -Wl,--defsym=__MPLAB_BUILD=1${...
0 votes
0 answers
33 views
How can I edit the Visual Studio compiler flags in the editor?
If I go to the "Project settings/configuration properties/C/C++/Command line" menu in the Visual Studio 2022 editor, how can I edit the compiler flags? I would like to remove one. I also ...
0 votes
0 answers
37 views
-finstrument-functions flag for aarch64-linux-gnu-g++ does not working
I've cross-compiled a small "hello world" app for my cortex-a72 CPU using -finstrument-functions flag (for debugging) in such way : "aarch64-linux-gnu-g++ -o0 -finstrument-functions ...
-1 votes
1 answer
143 views
g++ very different behaviour with vs without optimization flags [duplicate]
The following code gives drastically different results when compiling with any optimization flags vs without: #include <iostream> #include <cstdint> // trailing zero count for __uint128_t ...
3 votes
1 answer
207 views
Can I avoid explicitly specifying compiler flags to get a well-optimized build?
Suppose I have a CMake project which produces a CPU-intensive application. When I build binaries for execution on a given machine, or for performance benchmarking, I would like them to be maximally, ...
2 votes
1 answer
111 views
gcc compilation error on simple short int function call with flag -Werror=traditional-conversion
Compiling this C program with gcc 11.4.0 and -Werror=traditional-conversion raises an error: short int f(short int x); short int f(short int x) { return x; } int main(void) { short int a = 0;...
0 votes
1 answer
66 views
Can't set -fbracket-depth parameter for PYMC model compilation
I'm trying to train a pymc model (version 4.4.0) on a Mac. My model is fairly complex and it seems like the current level of complexity is causing the compiler some issues because I'm getting this ...
-1 votes
1 answer
160 views
CMAKE_CXX_FLAGS is not passed to compiler: why and how to fix?
I pass compiler flags by setting CMAKE_CXX_FLAGS via command line as: $ CC=my_llvm/clang CC=my_llvm/clang++ \ cmake -DCMAKE_AR=my_llvm/llvm-ar -DCMAKE_LD=my_llvm/lld \ -DCMAKE_CXX_FLAGS=--target=...
-1 votes
1 answer
119 views
Instantiate different classes according to different compilation flag of same header file in c++
I have a class that varies according to a compilation flag. I would like to instantiate both the versions of the class in the same scope. my_class.h #ifndef MY_CLASS_H #define MY_CLASS_H #ifdef ...
2 votes
2 answers
251 views
Why does my C++ code with a type mismatch compile without warnings using the GCC "-Wall" flag?
I have the following code: #include <iostream> char add(char a, int b) { return a + b; } int main(void) { long long a = 100000000; long long b = 20; int x = add(a, b); ...
1 vote
1 answer
518 views
GCC instruction scheduling: how do the algorithms differ?
GCC offers a number of options related to instruction scheduling in the compiler flags. An overview of what this means is on the GCC Wiki for "Instruction Scheduling", but this is well out ...
0 votes
2 answers
429 views
nvcc - add flags to a specific file using cmake
I am writing a CXX+CUDA project, and I'm compiling using nvcc, with CXX compiler of icpc. I want to add different compilation flags for icpc for different files. In CXX standalone this is possible ...
3 votes
1 answer
215 views
How can I specify flags for CMAKE_<LANG>_HOST_COMPILER?
CMake has a set of variables named CMAKE_<LANG>_FLAGS (CMAKE_CXX_FLAGS, CMAKE_Fortran_FLAGS etc.) which are used when building command-lines for compiling targets with the compilers for those ...
1 vote
1 answer
433 views
Improve g++ compiler flags for debug and release
I am making a game in c++ with sdl2, and I am currently compiling the program with g++ using the following flags: DEBUG_FLAGS = -g -Og -DDEBUG RELEASE_FLAGS = -O3 -DNDEBUG -mwindows -s I want the ...