Topic: PI definitions in several libs


Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 1999/01/24
Raw View
In article <36A842E3.3E11E811@geocities.com>, Falk Brettschneider
<F.Baldeweg@t-online.de> writes
>
>Hi,
>
>I've got this problem:
>MSVC++5.0 doesn't provide a PI = 3.14... So we want to define it for
>ourselves. But maybe there will be conflicts with other PI definitions
>of other C++ libraries we might include in the future.
>
>Furthermore, why will appear a compiler warning, if I define PI as
>"const double PI = 3.14...".
>
>Is this a known problem? Does any solution exist to prevent that
>conflicts?

Put it in a namespace and demand others do likewise.  That is what
namespaces are for.  And if you are sensible you will not spell that PI
but pi (consider the consequence of some library providing:
#define PI 3.14159265

Francis Glassborow      Chair of Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Ron Natalie <ron@sensor.com>
Date: 1999/01/24
Raw View
Falk Brettschneider wrote:
>
> Hi,
>
> I've got this problem:
> MSVC++5.0 doesn't provide a PI = 3.14... So we want to define it for
> ourselves. But maybe there will be conflicts with other PI definitions
> of other C++ libraries we might include in the future.
>
> Furthermore, why will appear a compiler warning, if I define PI as
> "const double PI = 3.14...".
>

Limit the scope with static or an unnamed namespace:

static const double PI = 3.14....
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: F.Baldeweg@t-online.de (Falk Brettschneider)
Date: 1999/01/22
Raw View
Hi,

I've got this problem:
MSVC++5.0 doesn't provide a PI = 3.14... So we want to define it for
ourselves. But maybe there will be conflicts with other PI definitions
of other C++ libraries we might include in the future.

Furthermore, why will appear a compiler warning, if I define PI as
"const double PI = 3.14...".

Is this a known problem? Does any solution exist to prevent that
conflicts?

-- Falk

------------------
mailto:gigafalk@geocities.com
look at: http://www.geocities.com/SiliconValley/Station/4004




[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Barry Margolin <barmar@bbnplanet.com>
Date: 1999/01/22
Raw View
In article <36A842E3.3E11E811@geocities.com>,
Falk Brettschneider <F.Baldeweg@t-online.de> wrote:
>I've got this problem:
>MSVC++5.0 doesn't provide a PI = 3.14... So we want to define it for
>ourselves. But maybe there will be conflicts with other PI definitions
>of other C++ libraries we might include in the future.
>
>Furthermore, why will appear a compiler warning, if I define PI as
>"const double PI = 3.14...".
>
>Is this a known problem? Does any solution exist to prevent that
>conflicts?

Isn't this what namespaces are for?

--
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "Michael J. Tobler" <unx5t!mtobler@no-spam-ibm.net>
Date: 1999/01/22
Raw View
Falk Brettschneider wrote:
>
> Hi,
>
> I've got this problem:
> MSVC++5.0 doesn't provide a PI = 3.14... So we want to define it for
> ourselves. But maybe there will be conflicts with other PI definitions
> of other C++ libraries we might include in the future.
>
> Furthermore, why will appear a compiler warning, if I define PI as
> "const double PI = 3.14...".
>
> Is this a known problem? Does any solution exist to prevent that
> conflicts?


Put it in a namespace.


--
<<<<<<<<<<< Blue Skies >>>>>>>>>>>>
<       Michael J. Tobler         >
< remove "no-spam"when replying   >
< mailto:mtobler@no-spam-ibm.net  >
< http://www.webbrew.com/toblermj >
<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]