User forums > Using Code::Blocks

How to expand compiler variable containing spaces without quotes

(1/5) > >>

ondra.holub:
Hello.

I have a compiler custom variable, which defines some compiler specific options for a certain library. They are of course different for different compilers and different platforms. Is there a way to expand such variable in Project->Build options|Compiler settings|Other options to be without double quotes?

For example when I have compiler variable COMPILER_OPTIONS set to -a -b -c I want to get in compiler's command line -a -b -c, not "-a -b -c". Currently I have compiler variable set to -a -b -c and in compiler options I have $COMPILER_OPTIONS. I tried $(COMPILER_OPTIONS), ${COMPILER_OPTIONS}, %COMPILER_OPTIONS% as well, but all of them are expanded with double quotes.

The only workaround I have found is to define COMPILER_OPTION1, COMPILER_OPTION2 etc. and use all of them (some of them may be empty). But this is quite ugly.

Thanks for any hint,
Ondrej

Freem:
Did you try the backslash?
When I use auto completion in folders with spaces in my terminal (I'm on Linux, so I'm not sure it will be portable on MS's OSes) it prefix spaces with them.
By example: "cd my\ dir"

But, why don't you use "other options" tab and the target system? It is made precisely for this kind of problem...

Open the properties of your project, then, "project's build options", next, go on a target you made for a special target (ie: a special OS, a special compiler, another problem, or a mix of some or all those problems), click on "Other options" tab, and just put your options here.

Alpha:
Assuming these are the type of variables you are talking about, the way I worked around it was by setting up the variable, saving the project, and closing Code::Blocks.  I then opened the project file (*.cbp) in a plain text editor (Notepad).  In the editor, search for the value of the variable (-a -b -c), and delete the string " from in-front and behind it.  Upon reopening the project it "should" work.

However, for your situation it sounds simpler to do what Freem suggested.

--- Quote from: Freem on September 26, 2011, 09:04:17 pm ---Open the properties of your project, then, "project's build options", next, go on a target you made for a special target (ie: a special OS, a special compiler, another problem, or a mix of some or all those problems), click on "Other options" tab, and just put your options here.

--- End quote ---

ondra.holub:
Thank you for hints. Well - create two targets dedicated to different platform (in my case linux and windows) is working solution I was using before. I have grouped "same" targets for different platforms to a single virtual target (for example "gcc all") and on each platform is the not matching target simply skipped. Maybe I will return to this approach.

The reason, why I wanted to define it this way is: I have more than one project using wxWidgets. Sometimes I change (upgrade) wxWidgets installation to a newer version. My idea is that then I will redefine some Code::Blocks variables and all projects remain working, because compiler's options are defined indirectly via these variables.

In meantime I have found other workaround which is enough for my usage: When I need to define additional parameters via some variable - for example -a -b -c I can define the variable as -a" "-b" "-c - it is expanded to "-a" "-b" "-c" which is correctly passed as command line arguments to compiler.

oBFusCATed:
ondra.holub: can you give detailed steps for reproducing this problem?

Navigation

[0] Message Index

[#] Next page

Go to full version