steinbergmedia / vstgui

A user interface toolkit mainly for audio plug-ins
Other
869 stars 124 forks source link

C++20 compile failure with GCC 11.2 #233

Closed sophiapoirier closed 3 years ago

sophiapoirier commented 3 years ago
../../vstgui/vstgui/lib/cviewcontainer.h:183:36: error: expected unqualified-id before ‘const’
  183 |                 Iterator<reverse> (const Iterator& vi) : children (vi.children), iterator (vi.iterator), riterator (vi.riterator) {}
      |                                    ^~~~~
tom7 commented 3 years ago

FYI I think that this can be fixed by removing <reverse> from the inline constructor.

scheffle commented 3 years ago

@sophiapoirier, please verify that my commit fixes this, thank you!

sophiapoirier commented 3 years ago

Thanks @scheffle! @tom7 who is the one who identified this and develops on Windows.

tom7 commented 3 years ago

Sorry, it still gives a syntax error with cfb0556057c1169df1dbbb068415ffed72fa1fbf. I would not claim to fully understand C++, but I think the problem is that the constructor is declared as Iterator<reverse>() instead of just Iterator(). Here's a simplified example:

// doesn't compile with g++ 11.2 -std=c++20
template<bool b>
class C {
 public:
  C<b>();
};

// ok
template<bool b>
class D {
 public:
  D();
};

And the same example on compiler explorer: https://godbolt.org/z/3rKd8djbx

scheffle commented 3 years ago

@tom7 , thanks for your support and the example. I think I've fixed this now. If you find the time, please verify the fix.

tom7 commented 3 years ago

Compiles for me with bfd2995ea5edb871eb85fd660ad70b5d7750d219 applied to the master branch. Thanks for fixing!

mxa commented 2 years ago

For the record Forcing GCC-10 on systems with newer default GCC works like this:

export CXX=/usr/bin/g++-10
export CC=/usr/bin/gcc-10

then configure and build.

https://stackoverflow.com/questions/17275348/how-to-specify-new-gcc-path-for-cmake