SDL_ttf.cpp (C++ compliant?)

Hello.

I’m using CodeWarrior under MacOSClassic and I am compiling C++.

The function “static int round(float)” defined in file “SDL_ttf.cpp"
makes an “illgal ambiguous access to overloaded function” with
"std::round(float)”.

Shouldn’t my compiler do so ?
I mean is my compiler C++ compliant, is it an allowed behaviour ?

I propose the following modification in the code:

#ifndef __cplusplus
static int round(float x)
{

}
#endif

thanks for answers!

Luc-Olivier

At 4:58 Uhr -0700 29.04.2001, Luc-Olivier de Charri?re wrote:

Hello.

I’m using CodeWarrior under MacOSClassic and I am compiling C++.

The function “static int round(float)” defined in file “SDL_ttf.cpp"
makes an “illgal ambiguous access to overloaded function” with
"std::round(float)”.

Shouldn’t my compiler do so ?
I mean is my compiler C++ compliant, is it an allowed behaviour ?

Actually, normally this shouldn’t happen. The C lib “round” function
is defined inside the namespace std::, as you can see above. My bet
is that somewhere in either your code or in SDL_ttf’s code, there is
a “using namespace std;” lurking around. This is a very dangerous and
depracted usage, you basically never should use it!
Second possibility is that there is a “using std::round;” somewhere.

Lastly, there might be a problem with the MSL of your version of
CW… what version do you use?

Max–

Max Horn
C++/ObjC/Java Developer

email: mailto:Max_Horn
phone: (+49) 6151-494890

At 4:58 Uhr -0700 29.04.2001, Luc-Olivier de Charri?re wrote:

Hello.

I’m using CodeWarrior under MacOSClassic and I am compiling C++.

The function “static int round(float)” defined in file “SDL_ttf.cpp"
makes an “illgal ambiguous access to overloaded function” with
"std::round(float)”.

SDL_ttf 2.0 doesn’t use the round() function, so you should be fine
as soon as it is released. You can get a preview at:
http://www.libsdl.org/cvs/SDL_ttf-2.0.2.tar.gz

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Isn’t it required to declare “using namespace std” when using the STL? I’d
think it would be bad practice to declare functions that have the same name
as standard library functions.> Actually, normally this shouldn’t happen. The C lib “round” function

is defined inside the namespace std::, as you can see above. My bet
is that somewhere in either your code or in SDL_ttf’s code, there is
a “using namespace std;” lurking around. This is a very dangerous and
depracted usage, you basically never should use it!

“David Phillips” wrote in message
news:003b01c0d11e$c5331fe0$0201a8c0 at brinstar…

Isn’t it required to declare “using namespace std” when using the STL?
I’d
think it would be bad practice to declare functions that have the same
name
as standard library functions.

I’d say “using namespace std” is a bad practice. Explicitly qualifying all
standard library names increases code clarity and greatly reduces the threat
of namespace collisions.–
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

I’d say “using namespace std” is a bad practice. Explicitly qualifying all
standard library names increases code clarity and greatly reduces the threat
of namespace collisions.

Okay, although interesting, this is off-topic.
The problem is not present in SDL_ttf 2.0.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

I’d say using namespace std is needed! Otherwise the compiler uses the
pre-ANSI functions and that’s bulls**t. :slight_smile: It took me one day to find out
why the and don’t work together. Since I’m using the
compiler flag -using_std, what is equal to put “using namespace std” in
every file and work well.
First I also thought this using stuff isn’t a good idea and if someone can
tell me a way avoiding this I’d be glad!> -----Original Message-----

From: Rainer Deyke [mailto:root at rainerdeyke.com]
Sent: Monday, April 30, 2001 6:42 AM
To: sdl at lokigames.com
Subject: [SDL] Re: SDL_ttf.cpp (C++ compliant?)

“David Phillips” wrote in message
news:003b01c0d11e$c5331fe0$0201a8c0 at brinstar…

Isn’t it required to declare “using namespace std” when
using the STL?
I’d
think it would be bad practice to declare functions that
have the same
name
as standard library functions.

I’d say “using namespace std” is a bad practice. Explicitly
qualifying all
standard library names increases code clarity and greatly
reduces the threat
of namespace collisions.


Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

I’d say using namespace std is needed! Otherwise the compiler uses the
pre-ANSI functions and that’s bulls**t. :slight_smile: It took me one
[snip]
First I also thought this using stuff isn’t a good idea and
if someone can
tell me a way avoiding this I’d be glad!

Well, by using ‘using namespace std’, you put all symbols declared in that
namespace in the global namespace (which goes against one of the main
reasons to have namespaces in the first place). You’re much better of
putting std:: in front of all stl symbols you use, or if that’s a problem,
explicitly state each item being used from the namespace :

using std::vector;
vector < long > v; // …> -----Original Message-----

From: Fuchs Hans [mailto:Hans.Fuchs at ch.telegyr.com]

I’d say using namespace std is needed! Otherwise the compiler uses the
pre-ANSI functions and that’s bulls**t. :slight_smile: It took me one day to find out
why the and don’t work together. Since I’m using the
compiler flag -using_std, what is equal to put “using namespace std” in
every file and work well.
First I also thought this using stuff isn’t a good idea and if someone can
tell me a way avoiding this I’d be glad!

Please respond via private e-mail, this is completely off-topic.

Thanks!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software