PHOTOOG Photography writings by Olivier Giroux

6Jun/073

Interesting VC++ Behavior

I wish I knew where knowledge about these things is posted. Googling about this stuff is nigh-impossible, yet I'm sure I'm not the first one to have hit this.

Steve: if you know I'll be glad to know.

So I have this code :

template < class DestT , class SrcT >
struct Converter {
  static bool convert( DestT &dst , SrcT const&src );
};

Which I was calling this way by mistake...

return Converter::convert<T,std::string>( t , s );

...and VC++ (2005) liked it. Amazing but true!

If you don't see it yet, this is the correct way to call this...

return Converter<T,std::string>::convert( t , s );

...because the function isn't templated but the class is.

Looks like there is an equivalency between functions of templated classes and templated functions off of non-templated classes in the Microsoft lookup. Of course G++ spat this back out the minute I moved my code to Linux.

Now for added entertainment value to the VC++ people, here's the cryptic GCC 3.3-or-older error message:

error: parse error before `;' token

If you've ever worked with GCC you'll recognize the dreaded "parse error before ;" message, which just about any error triggers. This has got to be the single largest source of cussing in my life.

Now, they majorly improved things afterwards with 3.4-and-later (but I'm stuck with 3.3 for my main build):

error: `template struct Converter' used without template parameters


Filed under: Uncategorized Leave a comment
Comments (3) Trackbacks (0)
  1. I haven’t found anything at
    http://connect.microsoft.com/feedback/default.aspx?SiteID=210

    But it’s the place where it should go 😉

  2. I thought I was the largest source of cussing in your life. At least I secretly hoped I was.

  3. Oh you’re up there…


Leave a comment

No trackbacks yet.