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
33
votes
2 answers

Why can't clang enable all sanitizers?

Clang has various sanitizers that can be turned on to catch problems at runtime. However, there are some sanitizers that I can't use together. Why is that? clang++-3.9 -std=c++1z -g -fsanitize=memory -fsanitize=address -o main main.cpp …
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
29
votes
5 answers

Optimization and flags for making a static library with g++

I am just starting with g++ compiler on Linux and got some questions on the compiler flags. Here are they Optimizations I read about optimization flags -O1, -O2 and -O3 in the g++ manual page. I didn't understood when to use these flags. Usually…
Navaneeth K N
  • 15,295
  • 38
  • 126
  • 184
28
votes
4 answers

What does the "Prefer 32-bit" compiler flag mean for Visual Studio (C#, VB)?

Just got the Visual Studio 11 developer preview installed. I see a new option in the project properties called "Prefer 32-bit" when compiling a managed (C#, VB) application with the AnyCPU target specified. This doesn't appear to be an option for…
lightw8
  • 3,262
  • 2
  • 25
  • 35
26
votes
1 answer

Clang: Promoting all Warnings to Errors Except for …

In the project I currently am — and probably will for some time be — working on, we have decided to use the -Werror flag, as our previous “No warnings!” policy did not work out as intended. This, however, imposes a certain problem: API can no longer…
danyowdee
  • 4,658
  • 2
  • 20
  • 35
25
votes
1 answer

Variables optimized out with g++ and the -Og option

When I compile my C++ program with g++ using the -Og option I see variables that are , and also the current line sometimes skips around. Is this behaviour expected at this optimization level, or do I have some problem? The man page of…
Svaberg
  • 1,501
  • 1
  • 19
  • 40
25
votes
3 answers

Appending to CMAKE_C_FLAGS

I'm using CMake for a project that comes in two versions, one of which requires -lglapi and the other does not. So far the lines we used look like that: SET(CMAKE_C_FLAGS "-O3 -xSSE3 -restrict -lpthread -lX11 -ldrm") SET(CMAKE_CXX_FLAGS "-O3…
TobiSF
  • 253
  • 1
  • 3
  • 5
25
votes
5 answers

Is it possible to pass in command line variables to a bitbake build?

I have an OpenEmbedded environment using bitbake to do some builds. I wanted to get something "interactive" going on where bitbake would pause and ask for input then continue with the build but I've found out that's not possible. Since I can't do…
Mike
  • 47,263
  • 29
  • 113
  • 177
24
votes
1 answer

What's the difference among cflgs sse options of -msse, -msse2, -mssse3, -msse4 rtc..? and how to determine?

For the GCC CFLAGS options: -msse, -msse2, -mssse3, -msse4, -msse4.1, -msse4.2. Are they exclusive in their use or can they be used together? My understanding is that the choosing which to set depends on whether the target arch, which the program…
yaya
  • 351
  • 1
  • 2
  • 3
22
votes
1 answer

Meaning of the g++ flags "-Wall", " -W", and "-Werror"

What are these and what do they do? -Wall -W -Werror I am using the terminal in Ubuntu to compile programs with this command: g++ -Wall -W -Werror main.cpp -o exec What is the explanation?
Mudit Kapoor
  • 351
  • 2
  • 3
  • 9
22
votes
1 answer

What does CompileThreshold, Tier2CompileThreshold, Tier3CompileThreshold and Tier4CompileThreshold control?

HotSpot's tiered compilation uses the interpreter until a threshold of invocations (for methods) or iterations (for loops) triggers a client compilation with self-profiling. The client compilation is used until another threshold of invocations or…
Nathan
  • 8,093
  • 8
  • 50
  • 76
21
votes
1 answer

What flags does -march=native activate with Clang?

With GCC one is able to print out the specific flags that -march=native triggers. Is it possible to have Clang print similar information?
20
votes
7 answers

Why isn't there any compiler error when a return statement is not present?

Unlike Java, in C/C++ the following is allowed: int* foo () { if(x) return p; // What if control reaches here? } This often causes crashes and it is hard to debug problems. Why doesn't the standard enforce to have a final return for…
iammilind
  • 68,093
  • 33
  • 169
  • 336
20
votes
2 answers

What are my available march/mtune options?

Is there a way to get gcc to output the available -march=arch options? I'm getting build errors (tried -march=x86_64) and I don't know what my options are. The compiler I'm using is a proprietary wrapper around gcc that doesn't seem to like…
Brydon Gibson
  • 1,179
  • 3
  • 11
  • 22
20
votes
3 answers

Undefined behavior from pointer math on a C++ array

Why the output of this program is 4? #include int main() { short A[] = {1, 2, 3, 4, 5, 6}; std::cout << *(short*)((char*)A + 7) << std::endl; return 0; } From my understanding, on x86 little endian system, where char has 1…
Jacek Skiba
  • 251
  • 1
  • 8
19
votes
4 answers

How do I set unicode as character set in the ALL_BUILD and ZERO_CHECK Visual Studio 2013 projects that are generated by Cmake?

I am currently using CMake to create a bunch of Visual Studio 2013 projects and it works. However, the automatically created ZERO_CHECK and ALL_BUILD projects are set to use MBCS by default although I want them to use the Unicode character set. I…
Rémi Loze
  • 241
  • 1
  • 2
  • 8
1
2
3
31 32