Mar 15, 2011

Series on C++ Compiler Errors

This post is going to serve  as a table of contents to what I hope is a decently long series of posts on  common yet potentially confusing C++ compiler error messages. All the examples will come from using Eclipse and CDT with the NetBurner tool chain. In particular this means the GNU C++ 4.2.1 cross compiler for the m68K family that I use for embedded development. I suspect most if not all the entries in this series will  be neither NetBurner nor embedded specific. I will update this post as I add new entries. Also as a disclaimer let me state that a single compiler error messages can be triggered by many different mistakes. That's often why they're worded the way they are. I'm not editorializing about the messages themselves, I'm just taking the opportunity to point out one specific meaning of each particular compiler message. In fact, I'm pointing out the error I'm most likely to have made when I see the message.
  1. No Matching Functionfor a function you didn't think you were calling.
  2. Discards Qualifiers – when const correctness comes back to bite you.
  3. Class Does Not Name Type - those pesky using namespace statements.
  4. No Matching Function call – Template Edition. This one can happen when you don't explicitly state template types that can't be deduced.
  5.  Assignment to read only structure – or how const correctness can come back to bite you during maintenance.
  6. BadImageFormatException – OK it's not a compiler error it's a runtime exception error but it certainly fits the spirit of messages that say something without much clue as to what they really mean.
  7. Assignment of Data-member … in read-only structure. You only think it's not read only.

About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.