How to use C++ 20 in g++

C++20 features are available since GCC 8. To enable C++20 support, add the command-line parameter -std=c++20 For G++ 9 and earlier use -std=c++2a Or, to enable GNU extensions in addition to C++20 features, add -std=gnu++20

“not declared in this scope” error with templates and inheritance [duplicate]

myOption is not a dependent name, i.e. it doesn’t depend on the template arguments explicitly so the compiler tries to look it up early. You must make it a dependent name: template <typename InterfaceType> void ChildClass<InterfaceType>::set() { this->myOption = 10; } Now it depends on the type of this and thus on the template arguments. … Read more

What’s the best g++ optimization level when building a debug target?

GCC 4.8 introduces a new optimization level: -Og for the best of both worlds. -Og Optimize debugging experience. -Og enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience. … Read more

Why does alias template give a conflicting declaration?

The problem relies on SFINAE. If you rewrite your member function to be value_t<S<T>>, like the outside declaration, then GCC will happily compile it: template<class T> struct S { using value_type = int; static const value_t<S<T>> C = 0; }; template<class T> const value_t<S<T>> S<T>::C; Because the expression is now functionally equivalent. Things like substitution … Read more

std::this_thread::sleep_for() and GCC

Confirmed that it doesn’t work here as well. (Recent GCC 4.6 snapshot). You could do the obvious and simply define it before you include any std:: headers. A bit dirty but will work until GCC fixes it (unless this is intended behavior). The #define shouldn’t break anything anyways. Either in source or -D_GLIBCXX_USE_NANOSLEEP flag to … Read more

C to C++ table inline definition

You can mix C and C++ code easily. You should keep the C code to be compiled with C compiler (gcc), rest of the code can be C++ and be compiled with C++ compiler (g++). then link all object (.o) files together. like this: file name: a.c const char* aTable[12] = { [4]=”seems”, [6]=” it … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)