compiler-flags

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

眉间皱痕 提交于 2019-11-27 07:35:05
问题 When I compile my C++ program with g++ using the -Og option I see variables that are <optimized out> , 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 gcc says: -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

How do you disable the unused variable warnings coming out of gcc in 3rd party code I do not wish to edit?

只谈情不闲聊 提交于 2019-11-27 06:15:40
I'd like to know what switch you pass to the gcc compiler to turn off unused variable warnings? I'm getting errors out of boost on windows and I do not want to touch the boost code: C:\boost_1_52_0/boost/system/error_code.hpp: At global scope: C:\boost_1_52_0/boost/system/error_code.hpp:214:36: error: 'boost::system::posix_category' defined but not used [-Werror=unused-variable] C:\boost_1_52_0/boost/system/error_code.hpp:215:36: error: 'boost::system::errno_ecat' defined but not used [-Werror=unused-variable] C:\boost_1_52_0/boost/system/error_code.hpp:216:36: error: 'boost::system::native

Changing CMAKE_CXX_FLAGS in project

*爱你&永不变心* 提交于 2019-11-27 05:42:14
问题 I have the following content in my CMakeLists.txt: project( Matfile ) SET ( CMAKE_CXX_FLAGS "-std=c++0x" ) set ( SOURCES "foo.cpp" "bar.cpp" ) add_library( Matfile ${SOURCES} ) As you may imagine, what I want to do is to compile my C++ sources using the flag -std=c++0x (I'm using gcc and I need the C++11 features). Unfortunately, this does not work, in the sense that, when I use cmake to generate the makefiles, the variable CMAKE_CXX_FLAGS is completely void. How can I set this variable in

How does gcc's -pg flag work?

爱⌒轻易说出口 提交于 2019-11-27 05:25:24
问题 I'm trying to understand how the -pg (or -p ) flag works when compiling C code with gcc . The official gcc documentation only states: -pg Generate extra code to write profile information suitable for the analysis program gprof. You must use this option when compiling the source files you want data about, and you must also use it when linking. This really interests me, as I'm doing a small research on profilers - trying to pick the best tool for the job. 回答1: Compiling with -pg instruments

How to set CUDA compiler flags in Visual Studio 2010?

允我心安 提交于 2019-11-27 05:22:30
After persistently getting error : identifier "atomicAdd" is undefined , I've found the solution to be to compile with -arch sm_20 flag. But how to pass this compiler flag in VS 2010? I have tried like so under Project > Properties : But this apparently has had no effect and the error persists - what am I doing wrong? Many thanks. You can select the options for the GPU Code Generation in this dialog: In this case "compute_20" means that i am compiling for the virtual compute architecture 2.0 - virtual architecture influences the PTX generation stage. The second part that comes after the coma

Xcode 5 equivalent of NS_BLOCK_ASSERTIONS in Build Settings

限于喜欢 提交于 2019-11-27 03:21:06
问题 Until Xcode 5, Release builds could be prevented from including NSAssert statements and their variants, using the default Build Setting: OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; This setting can be found in project.pbxproj and is set in Xcode here: (Note that this grab was taken from an Xcode 4 project converted to Xcode 5.) Each target would inherit this setting in the Release build only. Obviously this was a good thing. Rather than crash immediately, the app would possibly struggle on

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

自古美人都是妖i 提交于 2019-11-27 02:04:50
问题 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 class libraries, just top-level apps. What does this flag indicate? 回答1: It likely indicates the app is AnyCpu but when 32 bit is available it shouold run as such. This makes sense - 64 bit apps use more memory, and sometimes you just dont need the

Useful GCC flags for C

ぐ巨炮叔叔 提交于 2019-11-26 21:12:22
Beyond setting -Wall , and setting -std=XXX , what other really useful, but less known compiler flags are there for use in C? I'm particularly interested in any additional warnings, and/or and turning warnings into errors in some cases to absolutely minimize any accidental type mismatches. Several of the -f code generation options are interesting: The -ftrapv function will cause the program to abort on signed integer overflow (formally "undefined behaviour" in C). -fverbose-asm is useful if you're compiling with -S to examine the assembly output - it adds some informative comments.

Is optimisation level -O3 dangerous in g++?

回眸只為那壹抹淺笑 提交于 2019-11-26 19:18:59
I have heard from various sources (though mostly from a colleague of mine), that compiling with an optimisation level of -O3 in g++ is somehow 'dangerous', and should be avoided in general unless proven to be necessary. Is this true, and if so, why? Should I just be sticking to -O2 ? PlasmaHH In the early days of gcc (2.8 etc.) and in the times of egcs, and redhat 2.96 -O3 was quite buggy sometimes. But this is over a decade ago, and -O3 is not much different than other levels of optimizations (in buggyness). It does however tend to reveal cases where people rely on undefined behavior, due to

How to see which flags -march=native will activate?

时光怂恿深爱的人放手 提交于 2019-11-26 19:17:34
I'm compiling my C++ app using GCC 4.3. Instead of manually selecting the optimization flags I'm using -march=native , which in theory should add all optimization flags applicable to the hardware I'm compiling on. But how can I check which flags is it actually using? You can use the -Q --help=target options: gcc -march=native -Q --help=target ... The -v option may also be of use. You can see the documentation on the --help option here . elias To see command-line flags, use: gcc -march=native -E -v - </dev/null 2>&1 | grep cc1 If you want to see the compiler/precompiler defines set by certain