3

When use Eclipse with MinGW(version:4.8.1) to compile the following code fragement, it can pass but Eclipse still report: "Multiple markers at this line - Type 'alignas' could not be resolved"

template<typename X> void set_aside(std::vector<X> vx) {
    constexpr int max_buf = 1024;
    alignas(X) X buffer[max_buf];

    int max = min(vx.size(), max_buf / sizeof(X));
    std::uninitialized_copy(vx.begin(), vx.begin() + max, buffer);
}

What happend with this issue, although the code fragement pass the comiple,yet Eclipse marks with error. Someone have ever met this issue? Please kindly help me to resolve this issue,thanks very indeed!

TemplateRex
  • 69,038
  • 19
  • 164
  • 304
Cendey
  • 31
  • 1
  • 1
    Try moving `alignas(X)` after `X` in the declaration, I remember it has a specific order. – Vittorio Romeo Sep 23 '13 at 10:06
  • While the ISO IEC 14882-2011 Specification gives the definition as above code fragement.The following is the example of this sepcification: alignas(T) T buffer[N] – Cendey Sep 23 '13 at 10:09
  • 1
    If move alignas(X) after X,compiler complains that "warning: attribute ignored [-Wattributes] X alignas(X) buffer[max_buf];" – Cendey Sep 23 '13 at 10:14
  • 5
    I'd guess the Eclipse parser is not up to date with C++11. If your IDE errors on something the compiler accepts, just ignore the IDE. – Angew is no longer proud of SO Sep 23 '13 at 10:22
  • The latest Eclipse Kepler has much better C++11 support for static syntax checking. – TemplateRex Sep 23 '13 at 10:26
  • Yeah, looks like the known issue with Codan, the static analyzer. Related questions: [Disable Eclipse's error discovery. (c++11 false positives)](http://stackoverflow.com/q/13458396/341970) or [Turn off eclipse errors (that arent really errors)](http://stackoverflow.com/q/14131939/341970) for example. – Ali Sep 23 '13 at 11:42

1 Answers1

2

Many IDEs use a front-end syntax checker that is different than their back-end compiler. Eclipse Kepler (released June 2013) is mostly up-to-date with C++11 syntax, although some things like alignment support and the interaction with in-class initializers and default constructors might not be fully supported (yet). Similary, C++14 features like decltype(auto) will work if the back-end compiler is called with std=C++1y but will not be recognized by the front-end syntax checker.

NOTE: this is not unique to Eclipse, also Visual C++ Intellisense is sometimes running behind (especially in CTP versions) the actual compiler, causing the red squiggly lines.

TemplateRex
  • 69,038
  • 19
  • 164
  • 304