Template redefinition problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lomat

    Template redefinition problem

    Hello,

    While compiling a file, I get following error ....

    =============== =============== ===
    /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/type_traits.h:1 4
    2: redefinition of `struct __type_traits<s hort int>'
    /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/type_traits.h:1 0
    2: previous definition here
    =============== =============== ===


    If I open file
    /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/type_traits.h,
    the source code looks like below,
    =============== =============== ===
    94 #ifndef __STL_NO_BOOL
    95
    96 __STL_TEMPLATE_ NULL struct __type_traits<b ool> {
    97 typedef __true_type has_trivial_def ault_constructo r;
    98 typedef __true_type has_trivial_cop y_constructor;
    99 typedef __true_type has_trivial_ass ignment_operato r;
    100 typedef __true_type has_trivial_des tructor;
    101 typedef __true_type is_POD_type;
    102 };
    103
    104 #endif /* __STL_NO_BOOL */
    ....
    <snip>
    ....

    142 __STL_TEMPLATE_ NULL struct __type_traits<s hort> {
    143 typedef __true_type has_trivial_def ault_constructo r;
    144 typedef __true_type has_trivial_cop y_constructor;
    145 typedef __true_type has_trivial_ass ignment_operato r;
    146 typedef __true_type has_trivial_des tructor;
    147 typedef __true_type is_POD_type;
    148 };
    =============== =============== ===

    The macro __STL_NO_BOOL is NOT defined in my environment.

    If I pass the file through the precompiler (using command gcc -E <file name,
    inc paths etc.>), output shows above two templates as .....
    =============== =============== ===
    template<> struct __type_traits< short > {
    typedef __true_type has_trivial_def ault_constructo r;
    typedef __true_type has_trivial_cop y_constructor;
    typedef __true_type has_trivial_ass ignment_operato r;
    typedef __true_type has_trivial_des tructor;
    typedef __true_type is_POD_type;
    };
    ....
    <snip>
    ....
    template<> struct __type_traits<s hort> {
    typedef __true_type has_trivial_def ault_constructo r;
    typedef __true_type has_trivial_cop y_constructor;
    typedef __true_type has_trivial_ass ignment_operato r;
    typedef __true_type has_trivial_des tructor;
    typedef __true_type is_POD_type;
    };
    =============== =============== ===

    These two templates are causing the redefinition problem and it is clear
    that keyword "bool" is being resolved as "short".

    I am using GCC 2.95.3 on RedHat 8.0 on Intel PIII.

    - Can anyone give any directions regarding what could cause this problem?

    - Secondly, though in my opinion bool is being resolved as short, the error
    flagged by compiler says "redefiniti on of `struct __type_traits<s hort
    int>'". As a result, I am not sure if what I think is incorrect or "short"
    is same as "short int"?

    Thanks,


    Loma


  • Gianni Mariani

    #2
    Re: Template redefinition problem

    lomat wrote:
    [color=blue]
    >
    > I am using GCC 2.95.3 on RedHat 8.0 on Intel PIII.
    >
    > - Can anyone give any directions regarding what could cause this problem?[/color]

    Get a later version of the compiler. The latest (and best) version is
    gcc 3.3.1 and is significantly better than 2.9x .

    Comment

    • Attila Feher

      #3
      Re: Template redefinition problem

      lomat wrote:[color=blue]
      > These two templates are causing the redefinition problem and it is
      > clear that keyword "bool" is being resolved as "short".
      >
      > I am using GCC 2.95.3 on RedHat 8.0 on Intel PIII.
      >
      > - Can anyone give any directions regarding what could cause this
      > problem?[/color]

      Look for a header, included before that with "#define bool short".

      --
      Attila aka WW


      Comment

      • lomat

        #4
        Re: Template redefinition problem


        "Gianni Mariani" <gi2nospam@mari ani.ws> wrote in message
        news:bkn3qi$qef @dispatch.conce ntric.net...[color=blue]
        > lomat wrote:
        >[color=green]
        > >
        > > I am using GCC 2.95.3 on RedHat 8.0 on Intel PIII.
        > >
        > > - Can anyone give any directions regarding what could cause this[/color][/color]
        problem?[color=blue]
        >
        > Get a later version of the compiler. The latest (and best) version is
        > gcc 3.3.1 and is significantly better than 2.9x .
        >[/color]

        Thanks Gianni

        I can't use the latest GCC version 3.3, as the name mangling sheme it uses
        is different from the 2.95.x scheme.
        I tried using 3.3 but then I get zillions of linkage errors as the symbols
        from the libraries I use (which are built using 2.95.x) can't be resolved.
        The libraries that I use are non-open source (third party) and I can't build
        them using 3.3 as I don't have shource.
        As a result, I must use 2.95.x. Any suggestions?


        Comment

        • Gianni Mariani

          #5
          Re: Template redefinition problem

          lomat wrote:[color=blue]
          > "Gianni Mariani" <gi2nospam@mari ani.ws> wrote in message
          > news:bkn3qi$qef @dispatch.conce ntric.net...
          >[color=green]
          >>lomat wrote:
          >>
          >>[color=darkred]
          >>>I am using GCC 2.95.3 on RedHat 8.0 on Intel PIII.
          >>>
          >>>- Can anyone give any directions regarding what could cause this[/color][/color]
          >
          > problem?
          >[color=green]
          >>Get a later version of the compiler. The latest (and best) version is
          >>gcc 3.3.1 and is significantly better than 2.9x .
          >>[/color]
          >
          >
          > Thanks Gianni
          >
          > I can't use the latest GCC version 3.3, as the name mangling sheme it uses
          > is different from the 2.95.x scheme.
          > I tried using 3.3 but then I get zillions of linkage errors as the symbols
          > from the libraries I use (which are built using 2.95.x) can't be resolved.
          > The libraries that I use are non-open source (third party) and I can't build
          > them using 3.3 as I don't have shource.
          > As a result, I must use 2.95.x. Any suggestions?[/color]

          No easy ones.

          a) Time to go back to the supplier and get 3.3.1 binaries ?

          b) Stick to a subset of C++ that 2.95.x is happy with.

          c) Get the functionality from a different source that supplies 3.3.1
          binaries.

          Comment

          • tom_usenet

            #6
            Re: Template redefinition problem

            On Mon, 22 Sep 2003 21:05:23 +0530, "lomat" <atambe@ideas.c om> wrote:
            [color=blue]
            >
            >"Gianni Mariani" <gi2nospam@mari ani.ws> wrote in message
            >news:bkn3qi$qe f@dispatch.conc entric.net...[color=green]
            >> lomat wrote:
            >>[color=darkred]
            >> >
            >> > I am using GCC 2.95.3 on RedHat 8.0 on Intel PIII.
            >> >
            >> > - Can anyone give any directions regarding what could cause this[/color][/color]
            >problem?[color=green]
            >>
            >> Get a later version of the compiler. The latest (and best) version is
            >> gcc 3.3.1 and is significantly better than 2.9x .
            >>[/color]
            >
            >Thanks Gianni
            >
            >I can't use the latest GCC version 3.3, as the name mangling sheme it uses
            >is different from the 2.95.x scheme.
            >I tried using 3.3 but then I get zillions of linkage errors as the symbols
            >from the libraries I use (which are built using 2.95.x) can't be resolved.
            >The libraries that I use are non-open source (third party) and I can't build
            >them using 3.3 as I don't have shource.
            >As a result, I must use 2.95.x. Any suggestions?[/color]

            Try adding
            #define __STL_NO_BOOL 1
            to your project defines.

            Tom

            Comment

            Working...