1
votes

Eclipse CDT gives me a syntax error for a valid C++14 syntax. Everything compiles and runs but the syntax highlighting is broken.

I have MinGW and Eclipse running. The C++14 program compiles and executes but I get incorrect syntax highlighting / syntax checking.

Here is my source code:

#include <iostream>
auto main() -> int
{
    //Binary Literals C++14 with Digit separators C++14
    auto seven = int{0b0000'0111};

    std::cout << seven << std::endl;
    std::cout << __cplusplus << std::endl;
    return int{0};
}

And here is the output / build log. You can see my compiler settings
(-D__GXX_EXPERIMENTAL_CXX0X__ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++14) and the highlighting in it.

enter image description here

What do I need to setup so syntax detecition allows for C++14 syntax?

EDIT: it seems like the Indexer is the right bet - I am unable to make the Indexer work as intended.

On Windows 7 I am using MinGW. I open Providers and click on "CDT Built-In Compiler Settings MinGW" where I add -std=c++14. So the whole string is ${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}" -std=c++14 after I hit apply and ok I use Project->Index->rebuild in the hope of removing my errors. The Syntax error still persists.

This is essentially what is mentioned in the FAQ to get C++11 recognized by the indexer.

I have the latest MinGW Version installed. When I call g++ --version i get: g++ (GCC) 5.3.0 as a response. There is no manual for 5.3 but I would assume most of 5.4 is mostly valid for my version.

1
What message do you see when you hover over the highlighted line? - PeterSW
Ok I see it myself as just "Syntax error" rather than something more detailed. - PeterSW
@PeterSW: yeah - it actually just says Syntax Error - Johannes
Hovering over it and pressing F2 and then pressing the little icon at the bottom left sends me to the annotation preferences which suggest it's coming from the C/C++ Indexer. Maybe you could adjust the "Built in compiler settings" for the indexer as described in the last post here: eclipse.org/forums/index.php/t/1070790 - PeterSW
@PeterSW did not work for me yet - but I will retry tomorrow. I found a bugreport like that for c++11, I think you are on to something. https://bugs.eclipse.org/bugs/show_bug.cgi?id=471621 - Johannes

1 Answers

2
votes

The problem seems to be that the support for C++14 is not added yet.

Here is a bugreport that collects all C++14 issues. There is a depends on section where other bug reports alre listed. Among them the bug 451086 that specifically mentions Binary literals (N3472), Single-quotation-mark as digit separator (N3781).

So it seems like this issue is known and will be adressed at some point in the future.