Announcement

g++ Compile Errors

by hansonw1 on Dec 11, 2008 - 3:37:35 am UTC
  • (2/0)
Some tips about strange compile errors:
  • Weird stuff about iterators, templates, etc: this means one of your variables is using the name of a function
    (like min, count, fill) These functions are included by default in <iostream> in g++. (not in VC++)
  • Usually the name of the variable will be mentioned in the error.
  • math.h library errors (pow, sqrt) - For some reason g++ doesn't like it when you take the pow or sqrt with mixed types. (float, double or int, float for example)
  • To fix this, make everything a double. (e.g. use pow(double(x), 2.0) instead of pow(x,2) if you're getting this error.)
  • Try to avoid this: for (int i=0; i<N; i++) { code }. In g++, i goes out of scope after the for loop ends, whereas in VC++ it persists. This usually gives errors like "obsolete binding...".
Pay attention to the line numbers! especially "instantiated from".
If I've missed anything, please add to this post.

Comments (Search)

It's quiet in here...