What does the compile-time error “Undefined symbols for architecture x86_64” mean?

When you compile the file, the compiler invokes the linker which tries to generate an executable. But it cannot because you didn’t provide a function named main which is the function that will be executed when your program is launched. Either you don’t want to run the linker because you want to compile several files … Read more

Improving g++ output

GCC as of 4.9 has colourized output ☺ Append the following to your bashrc/zshrc/whatever. export GCC_COLORS=’error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01′

“warning: use of old-style cast” in g++ [duplicate]

reinterpret_cast, static_cast, dynamic_cast and const_cast are the c++ cast alternatives. const_cast to remove const/volatile from a const variable. dynamic_cast to perform runtime validity checks when casting in between polymorphic types static_cast to perform e.g up/down-cast in a inheritance hierarchy, but with no runtime checks, or to explicitly perform conversions that could be implicit (e.g. float … Read more

Strange std::map behaviour

This is actually a well-formed program that has two equally valid execution paths, so both compilers are right. a[1] = a.size() In this expression, the evaluation of the two operands of = are unsequenced. §1.9/15 [intro.execution] Except where noted, evaluations of operands of individual operators and of subexpressions of individual expressions are unsequenced. However, function … Read more

Why do I need to use typedef typename in g++ but not VS?

The typename is required by the standard. Template compilation requires a two step verification. During the first pass the compiler must verify the template syntax without actually supplying the type substitutions. In this step, std::map::iterator is assumed to be a value. If it does denote a type, the typename keyword is required. Why is this … Read more

Does the restrict keyword provide significant benefits in gcc/g++?

The restrict keyword does a difference. I’ve seen improvements of factor 2 and more in some situations (image processing). Most of the time the difference is not that large though. About 10%. Here is a little example that illustrate the difference. I’ve written a very basic 4×4 vector * matrix transform as a test. Note … Read more

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