Questions tagged [compiler-flags]

Parameters that may be passed to a compiler affecting how compilation is carried out. These can have a variety of effects on the paths searched for external dependencies, optimization level, how source code is interpreted, code checks that are performed and preprocessor directives.

Parameters that may be passed to a compiler affecting how compilation is carried out. These can have a variety of effects on the paths searched for external dependencies, optimization level, how source code is interpreted, code checks that are performed and preprocessor directives.

479 questions
9
votes
3 answers

What is the proper architecture-specific options (-m) for Sandy Bridge based Pentium?

I'm trying to figure out how to set -march option properly to see how much performance difference between the option enabled and disabled can occur on my PC with gcc 4.7.2. Before trying compiling, I tried to find what is the best -march option…
k2_8191
  • 407
  • 1
  • 5
  • 10
8
votes
2 answers

How to build a program with 2 different values of a variable in CMake

I've recently ported my Qt project from qmake to CMake. My main program contains a value which depends on a #define directive. I want to specify that define directive externally via CMake and build 3 differently named versions of the same…
linello
  • 8,451
  • 18
  • 63
  • 109
8
votes
1 answer

Xcode Project-Wide compiler flag

With Xcode 4.2 and the LLVM compiler, when compiling for ARMv6 there are some very weird bugs in the generated application (such as "width" property of CGSize returning the "height" instead). To fix this, I found I must set the compiler flag…
Riley Testut
  • 431
  • 1
  • 8
  • 22
8
votes
3 answers

Forbid integer conversion with precision loss

How to prevent such code from compiling? #include #include #include #include int main() { std::vector v; v.emplace_back(std::numeric_limits::max()); std::cout << v.back() <<…
8
votes
1 answer

Which compilation flags should I use to avoid run time errors

Just learned here that -Wsequence-point comiplation flag will pop a warning when the code can invoke UB. I tried it on a statement like int x = 1; int y = x+ ++x; and it worked very nicely. Until now I have compiled with gcc or g++ only using…
CIsForCookies
  • 12,097
  • 11
  • 59
  • 124
8
votes
1 answer

ARM Cortex-A8: How to make use of both NEON and vfpv3

I'm using Cortex-A8 processor and I'm not understanding how to use the -mfpu flag. On the Cortex-A8 there are both vfpv3 and neon co-processors. Previously I was not knowing how to use neon so I was only using gcc -marm -mfloat-abi=softfp…
HaggarTheHorrible
  • 7,083
  • 20
  • 70
  • 81
8
votes
1 answer

What does the -fPIC compilation flag does?

What the -fpic flag does? I want to install a library (OpenSFM) and it is stated that it will need the Ceres Solver built and installed with the -fPIC compilation flag. The problem is I already installed the Ceres Solver without the -fPIC flag and…
8
votes
4 answers

How to add compiler flags on codeblocks

I've been trying to compile a simple multithreaded piece of code I found online in an effort to learn how to multithread. To run this piece of code I need to use the compiler flags: -pthread and -std=c++0x. But whenever I try to add the flags the…
user3201708
  • 91
  • 1
  • 1
  • 5
8
votes
1 answer

What flag should I use to enforce a good C++11 style?

I am learning C++, and trying to write good code. I am currently using a lof of compiler flags, such as -Wextra -Wall -pedantic -Werror -Wfatal-errors -Wcast-qual -Wcast-align -Wconversion -Wdouble-promotion -Wfloat-equal -Wshadow -Wpointer-arith…
Tom Cornebize
  • 1,362
  • 15
  • 33
8
votes
2 answers

Clang not reporting uninitalized variables in C++?

I understand that local variables are not initialised automatically in C++, so before using them, you should always assign a value to them. However, at least in simple cases, the compiler should warn you in case you forget it. I'm more or less…
hagi
  • 11,503
  • 3
  • 35
  • 48
8
votes
1 answer

Does Clang have an equivalent to GCC's -malign-double flag?

It seems like the -malign-double compiler option has been removed from Clang. Example code: #include #include typedef struct X { char a; long long b; } X; int main(void) { printf("%zd\n", offsetof(X, b)); return…
Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
7
votes
1 answer

Mixing PIC and non-PIC objects in a shared library

This question is related to this one as well as its answer. I just discovered some ugliness in a build I'm working on. The situation looks somewhat like the following (written in gmake format); note, this specifically applies to a 32-bit memory…
Brian Vandenberg
  • 4,011
  • 2
  • 37
  • 53
7
votes
1 answer

Fast floating point model broken on next-generation intel compiler

Description I'm trying to switch over from using the classic intel compiler from the Intel OneAPI toolkit to the next-generation DPC/C++ compiler, but the default behaviour for handling floating point operations appears broken or different, in that…
Yattabyte
  • 1,280
  • 14
  • 28
7
votes
1 answer

What does clang++'s option -fno-strict-enums do?

Two months ago, I reported, as a clang++ bug, that the C++ program below sets z to 4294967295 when compiled with clang++ -O2 -fno-strict-enums. enum e { e1, e2 } e; long long x, y, z; char *p; void f(void) { e = (enum e) 4294967295; x =…
Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281
7
votes
1 answer

What does -Wall flag do when I compile it with the program?

I am following a tutorial that says how to profile the program using gprof and the command given is like this gcc -Wall -pg test_gprof.c test_gprof_new.c -o test_gprof But it doesn'y give any explanation for this flag (-Wall)