Thread: Internal Compiler Error

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Why would you need to remove a typename?
    Typename is required when using a dependant type.
    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. #17
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Beats me. I'm the C guy, you're the C++ one.
    Code:
    $ cat rectemp.cpp
    #include <iostream>
    
    using std::cout;
    
    template<int N> struct TemplateTest
    {
            static const int value = typename TemplateTest<N - 1>::value;
    };
    
    template<> struct TemplateTest<0>
    {
            static const int value = 0;
    };
    
    int main()
    {
            cout << TemplateTest<2>::value;
    }
    $ g++ rectemp.cpp -o rectemp
    rectemp.cpp:7: error: expected `(' before ';' token
    $
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #18
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Code:
    #include <iostream>
    
    using std::cout;
    
    template<int N> struct TemplateTest
    {
            static const int value = 1 + TemplateTest<N - 1>::value;
    };
    
    template<> struct TemplateTest<0>
    {
            static const int value = 0;
    };
    
    int main()
    {
            cout << TemplateTest<1000>::value;
    }
    +
    -ftemplate-depth-1000
    = success.

    Such things are (should be) configurable.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, beats me why it doesn't like the typename keyword. Visual C++ compiles fine either way (but it's known to compile without the typename keyword anyway).
    EDIT: Oh wait, I know. Of course, ::value is static, that's why it's not allowed.
    Last edited by Elysia; 07-04-2008 at 05:32 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.

  5. #20
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Oh wait, I know. Of course, ::value is static, that's why it's not allowed.
    No. You use 'typename' in that context to tell the language that you expect the nested type to be a type. In the error case it wasn't a type.

    Another fun internal error crash (for GCC and MSVC): use the relevant syntactical sugar--different for each compiler--to pass the address of a method to a template parameter and access that parameter in a context expected of a type. (The source should be flagged as illegal.)

    Soma

  6. #21
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by phantomotap View Post
    No. You use 'typename' in that context to tell the language that you expect the nested type to be a type. In the error case it wasn't a type.
    Yes, I realized. The constant is static and a type can't be static.
    If it weren't static, it wouldn't have compiled at all.
    Just shows that I'm not 100% used to advanced template programming yet, but I'm getting there
    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. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  3. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 09:09 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM