User forums > Using Code::Blocks
Conditional code in Code::Blocks project files
BlueHazzard:
in c::b you can use scripts in many pleases
for ex. in the compiler flags...
greetings
Ben Key:
+BlueHazzard
Once again I must ask for more information. It is not enough for you to simply tell me that scripts can be used in many places. I need specific information on exactly how to use scripts to conditionally add a compiler flag.
As I have already said, the syntax seems to be "<Add option={option} />." What I would like to know is exactly how to modify that so that an Add option line is conditionally evaluated. I know the syntax is [[{code}]] but I have seen nothing about how to combine this with an Add option line.
Jenna:
You should not touch the projectfile directly (except for very rare cases and if you know exactly what you do), or you might break it.
If you add the snippet posted by Tim in the "Other options" tab of the "Compilr settings" (either on project or target level), you will get the "-Wno-attributes" option added to your compiler options, if you are on windows (MSW) and have gcc >= 4.0 as compiler.
See:
http://wiki.codeblocks.org/index.php?title=Scripting
http://wiki.codeblocks.org/index.php?title=Variable_expansion
especially
http://wiki.codeblocks.org/index.php?title=Variable_expansion#Script_expansion
http://wiki.codeblocks.org/index.php?title=Scripting_commands
for the constants in the snippet:
http://wiki.codeblocks.org/index.php?title=Scripting_commands#Constants
Ben Key:
+jens
Thanks. That was what I needed to know.
I did notice that if I add two [[{code}]] lines in the "Other options" control I get errors related to there being a missing ;.
Navigation
[0] Message Index
[*] Previous page
Go to full version