SDL_ttf problem

Hi
I order to make my SDL Rocket platform game complete, I need to use SDL_ttf,
but even though I have been trying hard I can’t make it work. The showfont.c
example won’t compile using VC++6.0. Compiler error:
error C2065: ‘snprintf’ : undeclared identifier
The project init SDL and I have add SDL_ttf.h too. What am I doing wrong?
Thanks.
Jones_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

Hello

[…] I need to use SDL_ttf,
but even though I have been trying hard I can’t make it work. The
showfont.c
example won’t compile using VC++6.0. Compiler error:
error C2065: ‘snprintf’ : undeclared identifier
The project init SDL and I have add SDL_ttf.h too. What am I doing wrong?
I guess you’ve done nothing wrong… I’ve add the same problem with another
program a while ago… Seems like snprintf is not 100% portable :frowning:

Sam should either use sprintf there (which is portable)
or make some defines (it’s _snprintf under windows).

Regards,
Ga?tan.

Win32 calls it _snprintf() for some (probably incredibly evil) reason…
In Kobo Deluxe, I’ve solved it with some autoconf scripting. (The Win32
_snprintf() is at least sufficiently compatible with the real snprintf().)

1: In configure.in:
	AC_CHECK_FUNCS(snprintf _snprintf) 

2: In some apropriate .h file:
	#ifndef HAVE_SNPRINTF
	#define snprintf _snprintf
	#endif

(Well, if there’s no snprintf(), nor any _snprintf(), the code just won’t
build. Will that happen on the next major Windows release, maybe? :wink:

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Friday 07 December 2001 00:38, James Anderson wrote:

Hi
I order to make my SDL Rocket platform game complete, I need to use
SDL_ttf, but even though I have been trying hard I can’t make it work.
The showfont.c example won’t compile using VC++6.0. Compiler error:
error C2065: ‘snprintf’ : undeclared identifier

Hello

[…] I need to use SDL_ttf,
but even though I have been trying hard I can’t make it work. The

showfont.c

example won’t compile using VC++6.0. Compiler error:
error C2065: ‘snprintf’ : undeclared identifier
The project init SDL and I have add SDL_ttf.h too. What am I doing
wrong?

I guess you’ve done nothing wrong… I’ve add the same problem with
another program a while ago… Seems like snprintf is not 100% portable
:frowning:

Sam should either use sprintf there (which is portable)

Aaaargh! NEVER use that function! (Well, at least not unless you can
guarantee that the destination buffer won’t be overflowed…)

or make some defines (it’s _snprintf under windows).

Yeah, much better, IMO.

(Of course, the Win32 _snprintf() could be a fake… but they’re not
that evil, are they?)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Friday 07 December 2001 01:04, Gaetan de Menten wrote:

Sam should either use sprintf there (which is portable)
or make some defines (it’s _snprintf under windows).

Yes, I’ve already fixed it in CVS. I’m waiting on the MacOS build updates
to release the new code.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Win32 calls it _snprintf() for some (probably incredibly evil) reason…
In Kobo Deluxe, I’ve solved it with some autoconf scripting. (The Win32
_snprintf() is at least sufficiently compatible with the real snprintf().)

It’s not evil. snprintf() is not an ANSI function, and like all non-ANSI
functions in the C runtime, Microsoft flagged it with a ‘_’ char.

Do a “man snprintf” sometime and read the “CONFORMING TO” section.

–ryan.

“Ryan C. Gordon” wrote:

It’s not evil. snprintf() is not an ANSI function […]

the current ANSI C standard is from 1999 and includes snprintf()

It’s not evil. snprintf() is not an ANSI function […]

the current ANSI C standard is from 1999 and includes snprintf()

Then I’ll revise my statement: snprintf() is not an ANSI function in the
version of the ANSI standard that Visual C implements. :slight_smile:

–ryan.

Either way, I’ll keep looking up and using *snprintf(), rather than
having sprintf() corrupt my stack. I’ve gotten away with it so far… :slight_smile:

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Friday 07 December 2001 21:58, Ryan C. Gordon wrote:

It’s not evil. snprintf() is not an ANSI function […]

the current ANSI C standard is from 1999 and includes snprintf()

Then I’ll revise my statement: snprintf() is not an ANSI function in
the version of the ANSI standard that Visual C implements. :slight_smile: