User forums > Using Code::Blocks
C:B on Linux - defines with params - syntax error near unexpected token (
(1/1)
amarty:
Hello!
I am using C::B v. Release 8.02 under Windows and Linux.
In my project I add some defines in Project properties/Build options/Compiler settings/#defines
--- Quote ---_MY_STRINGISE(name)=#name
MY_STRINGISE(name)=_MY_STRINGISE(name)
--- End quote ---
Under Window/MinGW compiling is successfull, but under Linux/gcc I get an error:
--- Quote ---g++ -D_MY_STRINGISE(name)=#name -DMY_STRINGISE(name)=_MY_STRINGISE(name) ...
/bin/bash: -c: line 0: syntax error near unexpected token `('
--- End quote ---
It seems as the bash (sh) get wrong argument, I think it is need arguments to be quoted, like "-D...", but I can't found any option in C::B settings controling this.
Anybody knows solution for this problem?
Jenna:
--- Quote ----D name=definition
The contents of definition are tokenized and processed as if they appeared during translation phase three in a ‘#define’ directive. In particular, the definition will be truncated by embedded newline characters.
If you are invoking the preprocessor from a shell or shell-like program you may need to use the shell's quoting syntax to protect characters such as spaces that have a meaning in the shell syntax.
If you wish to define a function-like macro on the command line, write its argument list with surrounding parentheses before the equals sign (if any). Parentheses are meaningful to most shells, so you will need to quote the option. With sh and csh, -D'name(args...)=definition' works.
--- End quote ---
Quote from gcc-4.2 documentation.
Just quote the defines in the "Build options".
amarty:
--- Quote from: jens on September 16, 2008, 03:34:58 pm ---
--- Quote ----D name=definition
...
If you wish to define a function-like macro on the command line, write its argument list with surrounding parentheses before the equals sign (if any). Parentheses are meaningful to most shells, so you will need to quote the option. With sh and csh, -D'name(args...)=definition' works.
--- End quote ---
Quote from gcc-4.2 documentation.
Just quote the defines in the "Build options".
--- End quote ---
Now I correct defines to (in project build options):
--- Quote ---'_MY_STRINGISE(name)=#name'
'MY_STRINGISE(name)=_MY_STRINGISE(name)'
--- End quote ---
When compile, I get error from compiler:
--- Quote ---g++ -D'_MY_STRINGISE(name)=#name' -D'MY_STRINGISE(name)=_MY_STRINGISE(name)' ...
g++: argument to '-D' missing
--- End quote ---
I think It must be as below:
--- Quote ---g++ '-D_MY_STRINGISE(name)=#name' '-DMY_STRINGISE(name)=_MY_STRINGISE(name)' ...
--- End quote ---
but I don't know how to obtain this result. I think, the C::B must place all expression (with leadin -D) into quotes, but I can't find any option controling this.
Jenna:
Use double.quotes instead of single-quotes.
amarty:
It's work. Thanks :D
Navigation
[0] Message Index
Go to full version