error, conflicting types

U

user

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!
 
V

Victor Bazarov

user said:
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
 
U

user

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!
 
V

Victor Bazarov

user said:
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
 
A

Alf P. Steinbach

* Victor Bazarov:
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.
 
V

Victor Bazarov

Alf P. Steinbach said:
* Victor Bazarov:
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
 
R

rossum

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top