compiler-options

How can I set options in SConstruct for C compiler depending on compiler type?

百般思念 提交于 2019-12-07 06:53:43
问题 I need to set additional options for C compiler, e.g. add flag to turn all warnings ON, depending on the type of the compiler. E.g. for MSVC I should use env.Append(CPPFLAGS = "/Wall") but for mingw (gcc) I need to use: env.Append(CCFLAGS = "-Wall") How can I do this in scons way? 回答1: You could just check for the name of the compiler: cc = env['CC'] if cc == 'cl': env.Append(CPPFLAGS = '/Wall') elif cc == 'gcc': env.Append(CCFLAGS = '-Wall') 来源: https://stackoverflow.com/questions/1961164

Telling gcc diagnostics apart

独自空忆成欢 提交于 2019-12-07 05:30:30
问题 I have a problem interpreting gcc (4.8.2) warnings & errors. More precisely, it's difficult to tell where one problem ends and another one starts. I have console-only access to the build machine, so using an IDE is not an option. I really need to be able to tell individual issues apart quickly. Is there a way to make GCC insert something between distinct diagnostic messages? Here is an example output I am getting: /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src

Proper way of compiling OpenCL applications and using available compiler options

心已入冬 提交于 2019-12-06 09:35:06
I am a newbie in OpenCL stuffs. Whats is the best way to compiler an OpenCL project ? Using a supported compiler ( GCC or Clang ): When we use a compiler like gcc or clang , how do we control these options? Are they have to be set inside the source code, or, likewise the normal compilation flow we can pass them on the command line. Looking at the Khornos-Manual-1.2 , there are a few options provided for cl_int clBuildProgram for optimizations. : gcc|clang -O3 -I<INCLUDES> OpenCL_app.c -framework OpenCL OPTION -lm Actually, I Tried this and received an error : gcc: error: unrecognized command

Supressing PDB generation from the command line - C++

牧云@^-^@ 提交于 2019-12-06 06:49:17
I've had a search around and can find a few examples of using Visual Studio menus to suppress creation of PDB files. I need to do this for a project I'm building, however, this requires using the Visual Studio compiler from the command line only. Is there a command line switch for disabling PDB generation? When you navigate through project settings in Visual Studio, most options tell you what their equivalent command-line switch is. To disable link-time PDB generation, omit the /DEBUG switch. To disable compile-time PDB generation, omit the /Z switch ( /Z{7|i|I} ). [Edit] Oh, in fact if you

What's optimal march & mtune options for gcc for “Pentium4 and above” processors

女生的网名这么多〃 提交于 2019-12-06 06:39:29
问题 My C++ application (compiled using g++) needs to work on Pentium-4 (32-bit) and above. However, it's typically used with Core2Duo or better processors. I'm currently using: -march=pentium4 -mtune=pentium4 . But some reading has prompted me to think that -march=pentium4 -mtune=generic might be better. Can anybody shed some light on this? What are the optimal values for march & mtune options in this case? Platform: GCC 4.1.2 on RHEL 5.3 (32-bit). 回答1: That would be -march=pentium4 -mtune=core2

Why do common C compilers include the source filename in the output?

删除回忆录丶 提交于 2019-12-05 19:18:16
问题 I have learnt from this recent answer that gcc and clang include the source filename somewhere in the binary as metadata, even when debugging is not enabled. I can't really understand why this should be a good idea. Besides the tiny privacy risks, this happens also when one optimizes for the size of the resulting binary ( -Os ), which looks inefficient. Why do the compilers include this information? 回答1: The reason why GCC includes the filename is mainly for debugging purposes, because it

How do I find the latest Typescript target support for any version of node?

被刻印的时光 ゝ 提交于 2019-12-05 16:00:53
Assuming any version of Node, how do I find the corresponding Typescript Compiler Option for target that gives most the functionality? I want to remove the guest work. Specify ECMAScript target version: "ES3" (default), "ES5", "ES6"/"ES2015", "ES2016", "ES2017" or "ESNext". I run different versions of node, and I want to know when is the minimum node version to enable the different TSC targets. One method to accomplish this is to check out the site http://node.green . Find your version of node, and scroll down until the support for node features stops. So, for example, if you're using 10.3

Telling gcc diagnostics apart

大城市里の小女人 提交于 2019-12-05 09:23:28
I have a problem interpreting gcc (4.8.2) warnings & errors. More precisely, it's difficult to tell where one problem ends and another one starts. I have console-only access to the build machine, so using an IDE is not an option. I really need to be able to tell individual issues apart quickly. Is there a way to make GCC insert something between distinct diagnostic messages? Here is an example output I am getting: /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp: In member function ‘virtual bool xmodel::Core::DataItemCollection:

Compiler switch to disable const_cast semantics in c-style casts?

房东的猫 提交于 2019-12-05 08:29:48
Recently I stumbled over code such as this: void foo(const Bar* b) { ... takes_nonconst_param_fn((Bar*)b); ... Obviously, the developer didn't know what he was doing, but if the compiler hadn't silently accepted the c-style-cast and at least required a proper const_cast , he may have though twice before committing this. So this got me thinking, do any modern compilers have a switch to prevent const_cast semantics for c-style-casts? It's simply not practical to prevent all occurrences of c-style-casts and it's a necessary evil to allow their static_ and reinterpret_ semantics (if only for some

Visual C++ Compiler Optimization Flags: Difference Between /O2 and /Ot

你。 提交于 2019-12-05 05:43:41
What's the difference between the /Ot flag ("favor fast code") and the /O2 flag ("maximize speed")? (Ditto with /Os and /O1 .) /O1 and /O2 bundle together a number of options aimed at a larger goal. So /O1 makes a number of code generation choices that favour size; /O2 does the same thing and favours speed. /O1 includes /Os as well as other options. /O2 includes /Ot as well as other options. Some optimisations are enabled by both /O1 and /O2. And, depending on your program's paging behaviour, /O1 (size) can result in faster speed than /O2 if paging code comes to dominate your perf over