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
base: develop
from

Conversation

Projects
None yet
2 participants
@simap

simap commented Jan 11, 2017

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

simap added some commits Jan 11, 2017

set CMAKE_CXX_STANDARD for CLion syntax help
Without this set, CLion complains about many c++ features like std::unordered_map, lambdas, auto, etc.
@ivankravets

This comment has been minimized.

Show comment
Hide comment
@ivankravets

ivankravets Jan 12, 2017

Member

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

Thanks!

Member

ivankravets commented Jan 12, 2017

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

Thanks!

@ivankravets

This comment has been minimized.

Show comment
Hide comment
@ivankravets

ivankravets Jan 12, 2017

Member

Try to add to platformio.ini

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

Then, REBUILD_PROJECT_INDEX (target)

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

This comment has been minimized.

Show comment
Hide comment
@simap

simap 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 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

This comment has been minimized.

Show comment
Hide comment
@simap

simap 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 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

This comment has been minimized.

Show comment
Hide comment
@simap

simap commented Jan 12, 2017

Thanks!

@ivankravets

This comment has been minimized.

Show comment
Hide comment
@ivankravets

ivankravets Jan 12, 2017

Member

Thank you also! 👍

Member

ivankravets commented Jan 12, 2017

Thank you also! 👍

@ivankravets ivankravets referenced this pull request Mar 27, 2017

Closed

platformio 3.3.0 #11647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment