How to add compiler flags on codeblocks - gcc

I've been trying to compile a simple multithreaded piece of code I found online in an effort to learn how to multithread.
To run this piece of code I need to use the compiler flags: -pthread and -std=c++0x.
But whenever I try to add the flags the build log doesn't show them being used.
I've tried some generic tips online to get these to work, but none of them worked. Can someone help?
I've tried other advice online to add compiler flags to code blocks, but when I do that and check the build log none of them appear.

Because This Question was marked as Duplicate, even if doesn't have to do with it, because there is about Linker Flag and here is about Compiler Flags, I will post My answer HERE.
You will have to go to Settings -> Compiler... and next you'll have to click on Linker Settings TAB.
On the right side you will see Other Linker Options.
There you have to type -lpthread and press OK.
You may need to click on rebuild after that.

Open your project and then go Project > Build Options > Compiler Flags .
You can tick boxes in the "Compiler Flags" tab, and you can write other options in the "Other Options" tab.
Do one or the other, e.g. don't tick the "-std=c++98" box and also put "-std=c++11" in the Other Options. This will end up in both options being passed to the compiler.

Another option instead of using the "other options" is to create a custom compiler flag. So in addition to a compiler flag, you can specify a linker flag. In the case of the -pthread (which I also was having trouble with) it looked like it needed the linker flag as well, as mentioned by Michi
One can create a new compiler flag by right clicking and selecting the new option

add options: menu->project->properties->Build targets tab->Build options button

Related

Semantic Issue: Cannot use 'throw' with exceptions disabled (It's not warning, It's error)

I have already enabled exceptions on the project and/or target build settings. Project Navigator -> select project or target -> build settings -> Enable Objective-C Exceptions
but the exceptions are sill disabled.
Also, I watched some related post, but they are talking semantic issue is a warning, but mine is an error, I would be grateful if anyone can solve this problem.
I know it has been a long time but I had the same issue. I'd like to point out that you might also need to set the "Enable C++ Exceptions" option to "Yes". I set both that option and "Enable Objective-C Exceptions" to "Yes" but to no avail: I still had this problem. Afterwards, I found the option "Other Compiler Flags" and added the option "-fexceptions" and the build succeeded.
My guess is that some other custom settings override the exceptions flag.

Is it possible to disable specific compiler warnings?

I am trying to suppress specific compiler warnings, namely System.Data.OracleClient.OracleConnection' is obsolete. I came upon these questions here:
How to disable specific warnings for the entire solution?
Globally suppress c# compiler warnings
...but they don't seem to apply to VS2013. When I go to my project's properties, I don't see a Build tab. I see a Compile tab, but it doesn't appear to have a place to specify warning messages to suppress. I see a section there called Warning configurations, but I don't see the warning I am looking for.
Update: It turns out that I am trying to do this for VB.NET. Thanks to a link provided by the selected answer, you have to edit the project file's XML and supply the warning code in the <NoWarn></NoWarn> tag. However, you have to know the warning code which is hidden in the error list. One way to get it is to open the output window and build the project. In my case, the warnign code is 40000. It shows as BC40000, but I had to remove the BC. After rebuilding the project, the warning messages went away.
To suppress specific warnings for Visual C# or F#:
In Solution Explorer, choose the project in which you want to suppress warnings.
On the menu bar, choose View, Property Pages.
Choose the Build page.
In the Suppress warnings box, specify the error codes of the warnings that you want to suppress, separated by semicolons, and then rebuild the solution.
Check out here for more info on how to suppress specific warning for Visual C++ and Visual Basic.
Another ways is to use #pragma warning can enable or disable certain warnings.:
#pragma warning disable warning-list
#pragma warning restore warning-list
warning-list
A comma-separated list of warning numbers. Enter the numbers alone, without the "CS" prefix.
When no warning numbers are specified, disable disables all warnings and restore enables all warnings.
Yes, it is possible.
#pragma warning disable 'warning-number-list'
where warning-number-list is a comma separated list of warning numbers to disable, e.g. 1004
This will disable the warning from its point of declaration to the end of the current file unless re-enable with:
#pragma warning restore 'warning-number-list'.
These pragmas are placed inline in your code at the site of where you wish to disable/restore the warnings.
I believe there is also a place on the Project properties tabs to specify warnings to disable, as you mentioned.

GNAT GPS Debugger - Could not initialize the debugger

I am attempting to debug my project in GNAT's GPS IDE. Every time I chose Debug->Initialize->"program name" the gui of GPS switches to that of the debug GUI, and then an error pops up with "could not initialize the debugger".
The two possible solutions I have found are that gdb.exe may be out of date and it suggests running it outside of GPS, which it does run fine. The other possible solution is to make sure the -g tags are applied when building the project, as those are necessary for gnatlink and gcc for debugging. It also states that the -g tag is applied to a new project by default, unless you have specifically removed it. I doubt I have, but I am not sure where I would check that to make sure it is still included.
The other odd thing is that the tutorial that comes with GPS that runs through how to build and debug your code works perfectly fine when I initialize debugging on it. That tutorial I am referring to can be accessed through Help->GPS->GNAT Programming Studio Tutorial. It references the program 'sdc' which comes in the GNAT/2012/share/examples/gps/tutorial directory.
Any ideas on what I am doing incorrectly, since the error isnt very helpful?
Thanks!
At first it sorta sounds like a path problem, but if you're able to run a debugger tutorial that's probably not the case.
The behavior you're seeing if the program isn't compiled with the debug (-g) flag doesn't quite match my experience, but let's go ahead and check/set the debug flag anyway.
Select Project/Edit Project_Properties
Click the Switches tab.
Click the Gnatmake tab.
Check "Debug information". Note that a -g now shows up in the text box at the bottom of the tab page. Click OK on the dialog.
Recompile your code so that it uses the changed option. Select Build/Clean/Clean All, and OK any dialog that pops up.
Then do your build (you can just press F4).

How can I disable javascript compile warnings in VS 2010?

Visual studio seems intent that my javascript code is bad, mostly because it has no knowledge of jquery or some plugins I am using. Therefore, every time I compile my product it gives me a lot of warnings, most of them are incorrect ($ is not defined, window is not defined, etc...).
I have /// <reference path="" /> tags setup in my javascript with intellisense working properly so I know these are just not real issues.
How can I disable these warnings?
edit to be clear, I need these disabled because it's causing 100+ warnings that are making me lose sight of REAL c# warnings.
I had the exact same issue you were having: 100s of incorrect errors every save. For me the issue was with Chirpy, which was a prerequisite for another extension. For whatever reason on my end, Chirpy was not in my Extension Manager so it took me a while to find.
Check and see if you have it installed. If so disable JSHint.
Tool -> Options
Chirpy -> JSHint
Uncheck: Run JS Hint
try this and let me know if it works.
Enter the options through Tools > Options.
In the tree to the left, choose Text Editor > JScript > Miscellaneous. Uncheck "Show syntax errors".
I don't have a javascript source file on the computer I'm on at the moment to test this, but you may be able to use the #pragma command to disable particular warnings:
#pragma warning disable will disable all warnings, and #pragma warning restore will restore all warnings when placed at the end of your code block. You can also tell it to disable only particular warnings, such as #pragma warning disable 0219,0168.
http://abhijitjana.net/2010/08/27/how-to-suppress-complier-warning-using-pragma-warning-directives-in-visual-studio/
Interesting I am not able to reproduce your issue in neither VS2010 "website" project nor vs2010 "web application" project. It has to do with the add-ons that you installed. Probably you may have a setting in that add-on (who ever is causing this) to disable warnings.
To me the warning sounds like the add-on (who ever is causing this) is not intelligent enough. Try the below changes and see if that helps.
If you have master page then try move the jquery*.js script reference from master page to your actual page
Move all your javascript code into a js file instead of writing it them under script tag
Thanks,
Esen
What about this one?
To disable a single compiler warning
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Compile tab.
In the Warning configurations table, set the Notification value for the warning to None.
or perhaps this one
Tools > Options > Text Editor > JScript > Misc > Show errors as warnings( uncheck only this )

Disabling and enabling warning in xcode

Is it possible to disable warnings for particular piecies of code in xcode?
I'm using a library I didn't write myself, and it creates hundreds of warnings. This makes it very unclear to find warnings related to my code. Is it possible to disable when #import-ing the headers and re-enabling warnings immediately after?
I remember this was possible in some other IDE, maybe Visual Studio, maybe with some #pragma. Anything similar in xcode?
Thanks!
Open your project in XCode, then right click on your target in the Targets folder. Select "Get Info" form the drop down menu and then scroll down to the section for the compiler warnings (GCC 4.0 Warnings on my box). Here you can disable the checkboxes for the various warnings you have active. Also check the value of "Other Warning Flags". This could include -Wall or -WMost which will enable other warnings. You can remove that and hopefully your warnings will not appear.

Resources