Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set CMAKE_CXX_STANDARD for CLion syntax help #873

Closed
wants to merge 2 commits into from

Conversation

simap
Copy link

@simap simap commented Jan 11, 2017

Without this set, CLion complains about many c++ features like std::unordered_map, lambdas, auto, etc.

Without this set, CLion complains about many c++ features like std::unordered_map, lambdas, auto, etc.
@ivankravets
Copy link
Member

Could you provide a project example how to reproduce that? I tried different combination and don't see any complaints.

Thanks!

@ivankravets
Copy link
Member

ivankravets commented Jan 12, 2017

Try to add to platformio.ini

[env:myenv]
build_flags = -std=c++11

Then, REBUILD_PROJECT_INDEX (target)

@simap
Copy link
Author

simap commented Jan 12, 2017

Sure, this is a minimal program that can reproduce the issue in CLion (version 2016.3)

#include <Arduino.h>
#include <unordered_map>
#include <string>

std::unordered_map <std::string , double> varMap;

void setup() {
    varMap["test"] = 1.0;
}

void loop() {
}

Without set(CMAKE_CXX_STANDARD 11) I get this:
screen shot 2017-01-12 at 8 20 53 am

With it, I get no errors:
screen shot 2017-01-12 at 8 21 11 am

It compiles fine either way, but the IDE is unaware of the right C++ version.

Even without

[env:myenv]
build_flags = -std=c++11

The CMakeListsPrivate.txt file already contains that build flag:

SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-fno-rtti -fno-exceptions -std=c++11 -Os -mlongcalls -mtext-section-literals -falign-functions=4 -ffunction-sections -fdata-sections -DARDUINO=20300 -DLWIP_OPEN_SRC -DF_CPU=80000000L -D__ets__ -DICACHE_FLASH -DPLATFORMIO=30201 -DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12 -U__STRICT_ANSI__")

Adding it and regenerating with platformio init --ide clion doesn't seem to fix the IDE issues.

I think what is going on is that CLion is parsing everything itself and doesn't "see" the build flags, but instead relies on the set(CMAKE_CXX_STANDARD 11) line for its own internal parser.

@simap
Copy link
Author

simap commented Jan 12, 2017

Another hint, if I go in to the unordered_map include, the IDE grays out the wrong section of #if __cplusplus < 201103L when set(CMAKE_CXX_STANDARD 11) isn't set.

screen shot 2017-01-12 at 8 57 05 am

@simap
Copy link
Author

simap commented Jan 12, 2017

Thanks!

@ivankravets
Copy link
Member

Thank you also! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants