简体   繁体   中英

How can I specify Preprocessor directive from Eclipse CDT?

I would like to specify to the GCC C++ Compiler the following directive:

g++ -DPRODUCT=\"HFTLibrary.h\"

I can set this in the "Command" field of the Project Properties and works fine.

But I cannot set it as a Symbol: Name=PRODUCT Value=\\"HFTLibrary.h\\"

The final " character is deleted after I press OK

在此处输入图片说明

  1. Right click on your project and open the property dialog (or Alt+Enter)
  2. Go to C/C++ Build->Settings
  3. Activate Tool settings and look up your compiler (ie GCC C++ Compiler)
  4. Click on Preprocessor
  5. Click on Add and enter your symbol

... hmmmm... After testing this with my eclipse version Version: Mars Release (4.5.0) Build id: 20150621-1200 it seems there is a bug. It works for normal defines, but not when you try to define a string this way. If you don't put the quotes, then the define is added, but of course can not be used as a string in your code, and if you put the quotes it simply wraps the whole -D... in quotes which is wrong.

Anyway, setting it in the Path and Symbol property will not affect your Build, because this is only to tell where eclilpse can find includes and symbols for the indexer. For the build to be affected you must change it in the way as I described above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM