compiler-flags

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

妖精的绣舞 提交于 2019-12-20 08:03:31
问题 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 what optimization level do you use? The g++ manual says the following for -O2 . Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. The compiler does not perform loop unrolling or function

Compiler flags in Eclipse

不想你离开。 提交于 2019-12-20 06:37:03
问题 My build requires that I issue the following commands: $ g++ sniff.cpp -o sniff -lcrafter However, in my Eclipse build, all the complier gets is: g++ -o "sniffer_crafter" ./src/sniffer_crafter.o After getting these commands it complains that I have an undefined reference to the library Crafter. How can I resolve this linking issue using Eclipse? I have seen others answers to similar questions, but they don't seem to address Eclipse's current layout. I'm using the most recent edition of

What does CompileThreshold, Tier2CompileThreshold, Tier3CompileThreshold and Tier4CompileThreshold control?

一笑奈何 提交于 2019-12-17 23:22:17
问题 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 iterations triggers a server compilation. Printing HotSpot's flags shows the following flag values with -XX:+TieredCompilation. intx CompileThreshold = 10000 {pd product} intx Tier2CompileThreshold = 0 {product} intx Tier3CompileThreshold = 2000

How to disable “curses.h” header (a part of "stdio.h in Xcode 6.3 OSX Yosemite) to avoid conflicting function declarations

荒凉一梦 提交于 2019-12-17 21:16:48
问题 I'm trying to build a project in Xcode but I get errors Implicit declaration of function 'clear' is invalid in C99 and Conflicting types for 'clear' . Here's the code: //main.c #include <stdio.h> #include "tree.h" int main(){ clear(); // Implicit declaration of function 'clear' is invalid in C99 return 0; } //tree.c #include <stdio.h> #include "tree.h" void clear(){ ///Conflicting types for 'clear' printf("Command clear.\n"); } //tree.h #include <stdio.h> void clear(); ///Conflicting types

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

旧巷老猫 提交于 2019-12-17 08:10:18
问题 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 [

How can I compile this very big, but boring C source?

痞子三分冷 提交于 2019-12-13 15:26:27
问题 The central function in my code looks like this (everything else is vanilla input and output): const int n = 40000; double * foo (double const * const x) { double * y = malloc (n*sizeof(double)); y[0] = x[0] + (0.2*x[1]*x[0] - x[2]*x[2]); y[1] = x[1] + (0.2*x[1]*x[0] - x[2]*x[2]); // … // 39997 lines of similar code // that cannot be simplified to fewer lines // … y[40000] = 0.5*x[40000] - x[12345] + 5*x[0]; return y; } Assume for the purpose of this question that hard-coding these 40000

What does the flag “-D_POSIX_C_SOURCE=200112L” mean?

拥有回忆 提交于 2019-12-13 12:32:13
问题 Without it I can't use the libraries needed to connect to the internet, but I don't know what it means: -D_POSIX_C_SOURCE=200112L Can anyone explain? 回答1: POSIX has seen several revisions over time. Each new revision has changed the feature set that it supported. This macro defines which set of features you want your program will be built with. It influences how the include files are pre-processed, yielding different function prototypes. For example, some libries will check the POSIX_C_SOURCE

Pass output of command line utility to compiler/linker

心不动则不痛 提交于 2019-12-13 07:17:13
问题 I want to pass result of the getconf PAGESIZE command output as preprocessor define to my program in form of -DPAGESIZE=`getconf PAGESIZE` for [[gnu::assume_aligned(PAGESIZE)]] in custom allocator declaration. I tried the following: add_definitions(-DPAGESIZE=`getconf PAGESIZE`) But it expanded exactly as -DPAGESIZE="\`getconf" ... PAGESIZE` , where ... is contents of other CMAKE_CXX_FLAGS* . I.e. there is an issue with escaping of backticks in CMakeLists.txt files. How to properly pass such

Setting compiler specific flags in scons

让人想犯罪 __ 提交于 2019-12-13 01:35:57
问题 When writing a scons script that will be used on different platform and compiler it's sometimes desired to add compiler specific flags. Fx in pseudo code if using_gcc: env.Append( CCFLAGS=["-g"] ) elif using_msvc: env.Append( CCFLAGS=["/Zi"] ) At an earlier occation I just copied the appropriate(?) .py files under Tools and modified these and placed under site_tools , but that seems like a hackish solution. Is there a better way to achieve this result? It would of course be nice if it could

IMAGE_FILE_NET_RUN_FROM_SWAP in Delphi XE7

坚强是说给别人听的谎言 提交于 2019-12-12 03:17:08
问题 By writing a portable WIn32 app I want to make sure that all the proper settings are done. I googled for it and found the compiler IMAGE_FILE_NET_RUN_FROM_SWAP switch. I tried to include it in my dpr file just like this: {$SetPEFlags IMAGE_FILE_NET_RUN_FROM_SWAP} // THIS ONE! {$R *.dres} {$R *.res} Anyway Delphi XE7 says [dcc32 Error] Project1.dpr(330): E2003 Undeclared identifier: 'IMAGE_FILE_NET_RUN_FROM_SWAP' Anyway by reading Embarcaero wiki it seems the name is fine. Any suggestion? 回答1: