We required to use the CLANG compiler with the C99 standard and AddressSanitizer (ASAN) turned on, however I cannot figure out how to change these settings using the csupport plugin.
I have read the relevant sections of the help file but I'm still lost, any help would be appreciated.
Change the global variable g:C_CCompiler to clang and set the flags using g:C_CFlags
More information can be found here
Related
Is there any way to compile C code with c89 standard NOT c99 in Xcode (or another way with terminal)?
I've searched in Xcode settings but I didn't find any way to choose compiler or standard.
You should add -pedantic-errors to Other C flags in your project settings, like so:
Of course, don't forget to set the C language dialect to C89 as well.
This will give you the appropriate compile time errors when you try to compile something that is not valid C89.
Optionally, if you want Xcode to compile your code regardless of incompatibilities, but only give you yellow warnings at the problematic lines, use -pedantic instead of -pedantic-errors.
In a nutshell, these flags make the compiler stick to the language standard more strictly, as opposed to the default behavior, which is to attempt compiling the code any way possible.
I hope this helps :)
Source
(even though they mention this in the context of GCC, but the same flags apply for Clang as well)
I have a problem with the xlc compiler on BlueGene/q. The version of the xlc compiler is 12.1:
IBM XL C/C++ for Blue Gene, V12.1 Version: 12.01.0000.0000
According to the document1, it should support the compiler option "-qtm", which is used to enable the Transactional Memory. However, I always got the following error message:
Option -qtm is not valid. Enter xlc_r for list of valid options.
How can I figure it out? Any help is appreciated.
Are you invoking the compiler as bgxlc ?
I recently realized that I am not even in C99 mode after receiving the compile error
'for' loop initial declarations are only allowed in C99 mode
I found some advice on how to get to C99 via a quick search which has told me to go to Projects -> Properties... But alas, it is greyed out and I am not sure that is even the correct way to fix it (probably not available because my file is not a project, it is a normal source file). I have also seen a lot of similar questions saying to enable C99 mode so I have looked inside the compiler flags menu, but I cannot see anything about C99. I have tried some other flags such as In C Mode, support all ISO C90 programs..., but after I set this flag, I got more errors than I had before which seem to appear whenever the compiler finds comments inside main().
Note: Please don't just say to initialize the counter outside the for loop.
Update: While trying to compile outside of codeblocks with gcc, I tried
gcc -O2 -std=C99 filename.c, but received an error:
unrecognized command line option "-std=C99"
I use 64-bit Windows 7, CodeBlocks10.05, and GNU gcc.
For future reference, type in the flag -std=c99 in settings->compiler->other options which is not case-sensitive, however when compiling in a terminal the flag is case-sensitive. Thanks chris!
I'm trying to set option -fstack-protector-all in GCC 3.4.3 compiler for enabling some stack smashing protection scenarios. However when compiling with this i got error: unrecognized command line option "-fstack-protector-all"
. So seems this option isn't implemented in GCC 3.4.3 ?? or Am I missing something ?
If it is not implemented in older GCC compiler what is the best / easiest alternative to this ?
Or maybe some useful code pattern to implement stack-smashing protector in C code itself ?
Thanks
You seem to be only one minor version off a gcc version that seems to be able to provide you with this particular smash protection. I found this when googling:
http://www.research.ibm.com/trl/projects/security/ssp/
Maybe you could upgrade to that one (one minor number up) and still be compatible with your vendor?
Additionally, as at least for a number of years canary values are default set in gcc (no need to use the option you mention), have you looked at the disassembly of a simple program? If you see some storing/loading from a (gs) location near end of stack, it's already implemented.
I am using GCC crosscompiler to compile to an ARM platform. I have a problem where, using opitmization -O3 gives me a "bad immediate value for offset (4104)" on a temp file ccm4baaa.s. Can't find this file either.
How do I debug this, or find the source of the error? I know that it's located somewhere in hyper.c, but it's impossible to find it because there is no errors showing in hyper.c. Only the cryptic error message above.
Best Regards
Mr Gigu
There have been similar known bugs in previous releases of GCC. It might just be a matter of updating your version of the GCC toolchain. Which one are you using currently?
In order to debug the problem and find the offending source, in these cases it helps to add the gcc option -save-temps to the compilation. The effect is that the compiler keeps the intermediate assembly files (and the pre-processor output) for you to examine.