Jump to content
  • Advertisement
Sign in to follow this  
Diltsman

Template errors

This topic is 3987 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write a rather simple template function. It takes 3 template parameters, returns void, and takes 1 regular parameter. The first template parameter is the type of the pointer it takes. The second is the number of items the parameter is pointing to (array size), and the third is supposed to be a value from an enum to state how errors should be handled. When I compile I get the 2 following errors: error C2062: type 'char' unexpected error C2039: 'FAIL_UNRECOVERABLE' : is not a member of 'ErrorTypes' I am uncertain why I am getting the first error. The second, probably has something to do with using an enum rather than #defines, but I'm uncertain for that one too. As for the first template parameter, the only operation taken on it is sizeof(). I am using VC++6.0 (not certain what SP, if any, is installed). I would appreciate any information on what I am not understanding concerning templates and the like. enum ErrorTypes { FAIL_UNRECOVERABLE, FAIL_RECOVERABLE, FAIL_IGNORE }; template<typename type, int count, int error> void Pipe::Write(type * input) { ... } pipe.Read<char, SIZEOFHEADER, ErrorTypes::FAIL_UNRECOVERABLE>(headerbuffer);

Share this post


Link to post
Share on other sites
Advertisement
enum names don't live in a namespace created by the enum in C++. If you refer to FAIL_UNRECOVERABLE you do it without the ErrorTypes:: prefix.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
enum names don't live in a namespace created by the enum in C++. If you refer to FAIL_UNRECOVERABLE you do it without the ErrorTypes:: prefix.


Ok, I figured that, but for some reason it worked when I did ErrorTypes.FAIL_UNRECOVERABLE. Probably has to do with the compiler.

Thanks.

Share this post


Link to post
Share on other sites
VC++ 6.0 was released before the C++ standard. Templates are pretty wonky in that compiler. The express edition of Visual C++ 2005 is free, and handles template syntax quite well.

Share this post


Link to post
Share on other sites
Quote:
Original post by Diltsman
I am using VC++6.0

Templates in 6.0 are nigh-on unusable.

Share this post


Link to post
Share on other sites
Quote:
Original post by Valere
VC++ 6.0 was released before the C++ standard. Templates are pretty wonky in that compiler. The express edition of Visual C++ 2005 is free, and handles template syntax quite well.


Ok, this sucks. I would use VC++ 2005, except that, due to project requirements, I HAVE to use VC++ 6.0.

I mean, I could implement things by passing a void *, and some other stuff, but I hate doing that.

Share this post


Link to post
Share on other sites
Quote:
Original post by Diltsman
Ok, this sucks. I would use VC++ 2005, except that, due to project requirements, I HAVE to use VC++ 6.0.

What kind of project is that?
Sounds like a project you'd best avoid [wink]

Share this post


Link to post
Share on other sites
Quote:
Original post by Spoonbender
Quote:
Original post by Diltsman
Ok, this sucks. I would use VC++ 2005, except that, due to project requirements, I HAVE to use VC++ 6.0.

What kind of project is that?
Sounds like a project you'd best avoid [wink]


It's the good kind of project... The kind you get paid for.

Share this post


Link to post
Share on other sites
Quote:
Original post by Diltsman
Quote:
Original post by Spoonbender
Quote:
Original post by Diltsman
Ok, this sucks. I would use VC++ 2005, except that, due to project requirements, I HAVE to use VC++ 6.0.

What kind of project is that?
Sounds like a project you'd best avoid [wink]


It's the good kind of project... The kind you get paid for.


Man. If I had that kind of money, I would start paying people (lost wages and/or legal defense) to disclose the names of employers responsible for such disgustingly bad practice.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!