Andrew Tomazos
Andrew Tomazos

Reputation: 68698

Adding compiler switch to Eclipse CDT Built-In Compiler Settings generation?

I have a Makefile-based Eclipse CDT project, and under Project > Properties > C/C++ General > Preprocessor Include Paths, Macros etc. > GNU C++ > CDT GCC Built-in Compiler Settings > __cplusplus the value is 201402L

I have the -std=c++17 flag set in my Makefile, so the actual value of this predefined macro is 201703L not 201402L.

Clearly, the list of predefined macros in GCC Built-In Compiler Settings was generated without the -std=c++17 flag.

Is it possible to set the compiler flags that are used to generate the list of predefined macros in CDT GCC Built-in Compiler Settings and trigger them to be regenerated? If so where/how is this configured?

Upvotes: 1

Views: 1451

Answers (1)

HighCommander4
HighCommander4

Reputation: 52809

On the same preference page, if you switch to the Providers tab (rather than Entries), and select the CDT GCC Built-in Compiler Settings provider, there is a Command to get compiler specs there. You can modify that command, by e.g. adding -std=c++17. Pressing Apply on that page will automatically trigger the provider to run again and update the list of predefined macros.

You can also configure this workspace-wide in Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery tab. The Use global provider shared between projects checkbox (just above Command to get compiler specs) governs whether a project uses the workspace-wide settings, or its own.

Upvotes: 3

Related Questions