Thread: MSVC 6 SP5 template errors

  1. #1
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    MSVC 6 SP5 template errors

    I installed Service Pack 5 for MSVC 6 tonight and now all of my code that has templates is giving me run-time errors when a template function is called.

    For instance I wrote a templated function to handle releasing all of my DirectX objects that looks like this:
    Code:
    template<typename _T> void SafeRelease(_T T)
    {
       if(T)
       {
          T->Release();
          T=0;
       }
    }
    Where I pass my DirectX objects as the parameter in my destructors. Before the SP5 upgrade everything compiled and ran fine. Afterwards every time I exit (which is when SafeRelease is called by the respective destructors) I get an error.

    If I comment out the template function and replace it with a C-style macro that does the same thing the error is gone.

    I'm attaching a jpg of the error message.

    My question is does anyone know how to fix this (since you can't uninstall a service pack)? I've spent the last 3 hours on google and haven't found a solution yet.

    Thanks in advance.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Try doing a clean/rebuild all...if that doesn't work, try re-creating all your project/workspace files.

    gg

    [EDIT]
    Try this first, rename "_T" to "T" and call the variable "t". Names with leading underscores are reserved for the compiler.
    Last edited by Codeplug; 04-12-2003 at 09:21 AM.

  3. #3
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Weird. Not only did I have to recreate the project but I had to recreate the header file that had the definition of the templated functions. Copying/pasting it into the new project's directory and including it wouldn't work. I could copy/paste all the other files into the new project's workspace but I had to recreate that particular header from scratch.

    It's working fine now. Thanks. I was worried I'd have to reformat or something.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function template has already been defined
    By Elysia in forum C++ Programming
    Replies: 19
    Last Post: 04-14-2009, 10:17 AM
  2. template function v.s. template class
    By George2 in forum C++ Programming
    Replies: 3
    Last Post: 12-13-2007, 01:46 AM
  3. Specialising a member function with a template template parameter
    By the4thamigo_uk in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2007, 04:37 AM
  4. Compiling using g++ and getting errors...
    By alvifarooq in forum C++ Programming
    Replies: 2
    Last Post: 09-24-2004, 08:36 AM
  5. Template problem
    By LilShieste in forum C++ Programming
    Replies: 2
    Last Post: 12-09-2002, 01:17 PM