What does this do?

U

user

What's the meaning of these two lines?
extern const double __infinity;
#define INFINITY __infinity
 
V

Victor Bazarov

user said:
What's the meaning of these two lines?
extern const double __infinity;
#define INFINITY __infinity

AFAICT, the first one declares a const object of type 'double',
defined somewhere else in the program, and the second one kind of
give that object an additional name, "INFINITY". Actually, it
creates a macro named "INFINITY" that will if used in the code be
replaced with "__infinity".

The two lines are actually sort of unrelated. The first one is
used by the compiler, the second one by the preprocessor.

V
 
I

imanpreet

__infinity is defined externally to your file, while INFINITY serves as
a shorthand for __infinity.
 
C

CBFalconer

user said:
What's the meaning of these two lines?
extern const double __infinity;
#define INFINITY __infinity

It is connecting the identifier INFINITY (which is in your address
space) to the identifier __infinity (which is in the implementors
address space). What it actually does is going to be described in
your systems documentation. It is making it possible to revise
your program to fit some other system with relatively small
changes, whose purpose etc. should have been thoroughly documented
near those actual lines.
 

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

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,635
Latest member
SkyePurves

Latest Threads

Top