error, conflicting types

Discussion in 'C++' started by user, Jan 11, 2005.

  1. user

    user Guest

    Hi,

    I got this error and donno know how to fix it:

    In file included from ../except.h:53,
    from group.c:22:
    .../portspecs.h:81: error: conflicting types for `const double
    __infinity'
    /usr/include/math.h:26: error: previous declaration as `const __dmath
    __infinity[]'

    Thanks!
     
    user, Jan 11, 2005
    #1
    1. Advertising

  2. user wrote:
    > I got this error and donno know how to fix it:
    >
    > In file included from ../except.h:53,
    > from group.c:22:
    > ../portspecs.h:81: error: conflicting types for `const double
    > __infinity'
    > /usr/include/math.h:26: error: previous declaration as `const __dmath
    > __infinity[]'


    Find out which '__infinity' you actually want and try not to include the
    header that contains the other one. If you don't use either, and still
    need both headers (math.h and portspecs.h), try placing one of them or
    both in a namespace.

    Both seem non-standard, and are probably compiler-specific, so consider
    asking in a newsgroup dedicated to your compiler as well.

    V
     
    Victor Bazarov, Jan 11, 2005
    #2
    1. Advertising

  3. user

    user Guest

    I need both headers (math.h and portspecs.h), and I'm using the
    declaration of the one in portspecs.h.
    One thing I guess I can do is to modify or remove that declaration in
    math.h. But is there any other method I can keep math.h untouched, and
    do minimum change to other files as well?
    Thanks!
     
    user, Jan 11, 2005
    #3
  4. user wrote:
    > I need both headers (math.h and portspecs.h), and I'm using the
    > declaration of the one in portspecs.h.
    > One thing I guess I can do is to modify or remove that declaration in
    > math.h. But is there any other method I can keep math.h untouched, and
    > do minimum change to other files as well?


    Yes. You could surround the inclusion of 'math.h' or the other one with

    #define __infinity whatever_you_want
    #include <math.h>
    #undef __infinity

    which will cause the preprocessor to replace all __infinity occurrences
    with whatever_you_want, which will prevent the conflict. Play with this
    method to find the suitable combination of macro/inclusion.

    V
     
    Victor Bazarov, Jan 11, 2005
    #4
  5. * Victor Bazarov:
    > user wrote:
    > > I need both headers (math.h and portspecs.h), and I'm using the
    > > declaration of the one in portspecs.h.
    > > One thing I guess I can do is to modify or remove that declaration in
    > > math.h. But is there any other method I can keep math.h untouched, and
    > > do minimum change to other files as well?

    >
    > Yes. You could surround the inclusion of 'math.h' or the other one with
    >
    > #define __infinity whatever_you_want
    > #include <math.h>
    > #undef __infinity
    >
    > which will cause the preprocessor to replace all __infinity occurrences
    > with whatever_you_want, which will prevent the conflict. Play with this
    > method to find the suitable combination of macro/inclusion.


    (Discrete harking.) [math.h] is a standard header. Using macros that way
    may conflict with implementation files. It may be that [portspecs.h] has
    a conditional definition of __infinity, and that's worth checking out.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Jan 12, 2005
    #5
  6. "Alf P. Steinbach" <> wrote...
    >* Victor Bazarov:
    >> user wrote:
    >> > I need both headers (math.h and portspecs.h), and I'm using the
    >> > declaration of the one in portspecs.h.
    >> > One thing I guess I can do is to modify or remove that declaration in
    >> > math.h. But is there any other method I can keep math.h untouched, and
    >> > do minimum change to other files as well?

    >>
    >> Yes. You could surround the inclusion of 'math.h' or the other one with

    .. ^^^^^^^^^^^^^^^^
    >>
    >> #define __infinity whatever_you_want
    >> #include <math.h>
    >> #undef __infinity
    >>
    >> which will cause the preprocessor to replace all __infinity occurrences
    >> with whatever_you_want, which will prevent the conflict. Play with this
    >> method to find the suitable combination of macro/inclusion.

    >
    > (Discrete harking.) [math.h] is a standard header. Using macros that way
    > may conflict with implementation files. It may be that [portspecs.h] has
    > a conditional definition of __infinity, and that's worth checking out.


    It may be so, or it may not be so.

    A hack is a hack, whether it's applied to a header shipped with the
    language/library implementation or a header shipped with a third-party
    library. It is possible that tweaking the third-party header is safer.
    It is also possible that it's less safe.

    V
     
    Victor Bazarov, Jan 12, 2005
    #6
  7. user

    rossum Guest

    On 11 Jan 2005 14:46:52 -0800, "user" <> wrote:

    >Hi,
    >
    >I got this error and donno know how to fix it:
    >
    >In file included from ../except.h:53,
    >from group.c:22:
    >../portspecs.h:81: error: conflicting types for `const double
    >__infinity'
    >/usr/include/math.h:26: error: previous declaration as `const __dmath
    >__infinity[]'

    This __infinity comes from math.h. Perhaps it might be better to use
    cmath if that is possible. Just change:
    #include <math.h>
    to
    #include <cmath>
    if that is possible within your own code.

    rossum

    >
    >Thanks!


    --

    The ultimate truth is that there is no Ultimate Truth
     
    rossum, Jan 12, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2ZQ==?=

    Conflicting dependency error/warning message

    =?Utf-8?B?RGF2ZQ==?=, Oct 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    441
    =?Utf-8?B?RGF2ZQ==?=
    Oct 26, 2004
  2. Michael.Z
    Replies:
    11
    Views:
    825
    Michael.Zhang
    May 11, 2008
  3. dentzigui
    Replies:
    8
    Views:
    4,744
    Seebs
    Nov 1, 2009
  4. Skybuck Flying
    Replies:
    5
    Views:
    686
    ImpalerCore
    Nov 29, 2011
  5. Replies:
    1
    Views:
    135
Loading...

Share This Page