From: <dan...@ya...> - 2002-05-20 07:47:21
|
--- Oscar Fuentes <of...@wa...> wrote: > Danny Smith <dan...@ya...> writes: > > > --- Matthew Miller <ma...@ma...> wrote: > On Mon, May 20, > 2002 > > at 05:50:44AM +0200, Oscar Fuentes wrote: > > > > What we _never_ should do is to provide functionality other > than > > > the > MSVCRT and do not document them clearly on some highly > > > visible > document. > > > > > > That's probably reasonable. How about at least putting a warning > > > comment by _snprintf in the header files? ("Warning to Unix > > > programmers: this function might not do what you might expect it > > > to do.....") > > Well, except for totally beginners, every MinGW user knows he is > dealing with MSVCRT, so there is no need for warning people that > things can be different here from other systems. > > > Or just > > > > #ifndef __STRICT_ANSI__ > > /* with a more explicit comment on the differences between MSVCRT > > behaviour and C99 */ > > This on a README file plus at the beginning of each header file > should > be enough: > > "MinGW uses MSVCRT by default. If you want C99 to take precedence > over > MSVCRT functionality with the same name #define __STRICT_C99__. Not > all C99 functions are implemented. 'grep' for __STRICT_C99__ if you > want to know what's available." > > Although #defining a symbol is not enough, because some C99 functions > are too big for being implemented as macros. Maybe a compiler switch? > > -- > Oscar The "standard" guard is: #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L What I was thinking was something like this: #ifndef __STRICT_ANSI__ /* These are the pre-C99 versions in MSCVRT */ int _snprintf (char*, size_t, const char*, ...) int _vsnprintf (char*, size_t, const char*, __VALIST); #endif /* __STRICT_ANSI__ */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* These follow C99 specification. They live in libmingwex.a */ int snprintf(char* s, size_t n, const char* format, ...); int vsnprintf (char* s, size_t n, const char* format, __VALIST arg) #endif /* __STDC_VERSION__ >= 199901L */ Compiler switch -ansi turns on __STRICT_ANSI__ (C89 std) Compiler switch -std=c99 defines __STDC_VERSION__ = 199901L and also defines __STRICT_ANSI__ The wrappers need to be actual functions for C++, because the C++ standard says so. Also macro version get undefined by g++-v3 headers Danny http://briefcase.yahoo.com.au - Yahoo! Briefcase - Save your important files online for easy access! |