Template parameter is incompatible with the declaration

This is a discussion on Template parameter is incompatible with the declaration within the C++ Programming forums, part of the General Programming Boards category; Code: template<int> class Test2 {}; template<typename A, template<int> class B, int C> class Test { template<typename, template<int> class, int> friend ...

  1. #1
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548

    Template parameter is incompatible with the declaration

    Code:
    template<int> class Test2 {};
    template<typename A, template<int> class B, int C> class Test
    {
    	template<typename, template<int> class, int> friend class Test;
    };
    
    void FindFiles(Test<int, Test2, 10> pBuffer = 0);
    Error 1 error C3855: 'Test': template parameter 'B' is incompatible with the declaration
    Error 2 error C3855: 'Test': template parameter 'C' is incompatible with the declaration


    If I change the B and C to typename, it compiles fine, though. Any ideas?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,261
    The only obvious error I can spot with that code, on an admittedly casual look, is that the default value of the argument for FindFiles() is invalid (no obvious conversion of int to Test<int, Test2, 10> ).
    Right 98% of the time, and don't care about the other 3%.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    Yes, it would cause a compile error admittedly, but regardless of what I put there, and regardless of if it's a valid or invalid default value, the error still occurs.
    If I remove the default value, it compiles.
    I also can't get comeau's online compiler to work...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by Elysia View Post
    Yes, it would cause a compile error admittedly, but regardless of what I put there, and regardless of if it's a valid or invalid default value, the error still occurs.
    If I remove the default value, it compiles.
    I also can't get comeau's online compiler to work...
    Can you provide us with the shortest code snippet that produces this error ;-).

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    That is exactly what I gave you. Add int main(), compile, and lo and behold.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by Elysia View Post
    That is exactly what I gave you. Add int main(), compile, and lo and behold.
    Well, your sample compiles fine for me, -pedantic and -Wall and all. G++ version 4.4.1, ubuntu.
    So I guess your compiler is buggy.

    Just out of interest, what compiler is it?


    Edit:
    Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
    That explains it. Guess you're screwed here :P.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    Hrm. Guess I'm going to have to give VS2010 another go.
    EDIT: Buggy as hell as always. Crashes as soon as you try to compile. Still gives the same error, too.
    Last edited by Elysia; 04-04-2010 at 02:06 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    Jan 2007
    Posts
    330
    interesting code.
    Whats it supposed to do?

  9. #9
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by Elysia View Post
    EDIT: Buggy as hell as always. Crashes as soon as you try to compile. Still gives the same error, too.
    LOL .
    How can it crash AND produce that error, though? :P

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    Quote Originally Posted by KIBO View Post
    interesting code.
    Whats it supposed to do?
    This code? Nothing.
    The real code? Make all template instantiations friends of each other.

    Quote Originally Posted by EVOEx View Post
    LOL .
    How can it crash AND produce that error, though? :P
    It has enough time to spit out that error before crashing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assignment issues
    By Elysia in forum C++ Programming
    Replies: 6
    Last Post: 01-13-2010, 11:55 AM
  2. Replies: 2
    Last Post: 11-08-2007, 01:33 AM
  3. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 11:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21