[ros-users] How to debug the source code in C?

Brian Gerkey gerkey at willowgarage.com
Wed Aug 18 21:20:18 UTC 2010


On Wed, Aug 18, 2010 at 1:07 PM, Kei Okada <k-okada at jsk.t.u-tokyo.ac.jp> wrote:
> How to add compile definition with string variable, for example
> -DFOO="bar" in rosbuild_add_compile_flags?
>
> I tried
>
>  set(COMPILE_FLAGS "-O2 -DFOO=\"bar\")
>  rosbuild_add_compile_flags(hoge ${COMPILE_FLAGS})
>
> but, this did not works well, it seems compile with
>  gcc -O2 -DFOO=bar.

Here's how rosbuild does something similar, where PROJECT_NAME is an
unquoted string:

  add_definitions(-DROS_PACKAGE_NAME='\"${PROJECT_NAME}\"')

Note the outer single quotes, and escaped double quotes.  I suspect
that there are alternatives that would also work.

Btw, CMake usually takes -D definitions via add_definitions(), as in
this example.  But adding them via rosbuild_add_compile_flags() will
also work.

	brian.



More information about the ros-users mailing list