Strange code that compiles with g++

According to the C++ Standard (p. #6 of section 7 Declarations) 6 Each init-declarator in the init-declarator-list contains exactly one declarator-id, which is the name declared by that init-declarator and hence one of the names declared by the declaration So it is simply a compiler bug. The valid code could look as for example (apart … Read more

GCC C++ Linker errors: Undefined reference to ‘vtable for XXX’, Undefined reference to ‘ClassName::ClassName()’

This linker error usually (in my experience) means that you’ve overridden a virtual function in a child class with a declaration, but haven’t given a definition for the method. For example: class Base { virtual void f() = 0; } class Derived : public Base { void f(); } But you haven’t given the definition … Read more

Dump include paths from g++

From Jonathan Wakely a better option (works on clang too): g++ -E -x c++ – -v < /dev/null clang++ -E -x c++ – -v < /dev/null I noticed there’s a flag in cpp for specifying language. This works like a charm. cpp -xc++ -v < /dev/null #include “…” search starts here: #include <…> search starts … Read more

How to compile C++ with C++11 support in Mac Terminal

As others have pointed out you should use clang++ rather than g++. Also, you should use the libc++ library instead of the default libstdc++; The included version of libstdc++ is quite old and therefore does not include C++11 library features. clang++ -std=c++11 -stdlib=libc++ -Weverything main.cpp If you haven’t installed the command line tools for Xcode … Read more

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