2000-08-11 22:00:49 +00:00
|
|
|
/*
|
2002-09-12 21:26:51 +00:00
|
|
|
* $Id: snprintf.h,v 1.9 2002/09/12 21:26:51 gram Exp $
|
2000-08-11 22:00:49 +00:00
|
|
|
*/
|
2000-08-11 13:37:21 +00:00
|
|
|
|
|
|
|
#ifndef __ETHEREAL_SNPRINTF_H__
|
|
|
|
#define __ETHEREAL_SNPRINTF_H__
|
|
|
|
|
Some compilers, e.g. Microsoft Visual C++, don't define __STDC__ unless
extensions to ANSI C are disabled if they may cause strictly conforming
programs not to compile, or to work differently if those extensions are
enabled. (Other compilers #define it as 0, e.g. Sun's and, I think,
other AT&T-derived compilers; still others cheerfully define it as 1
even when those extensions are enabled, e.g. GCC.)
As such, checking whether __STDC__ is defined, or is defined as a
non-zero value, isn't the right way to check whether function prototypes
are supported; MSVC++ 6.0 supports them, but, by default, leaves
extensions of the sort described above enabled, and thus doesn't define
__STDC__. This means that the compiler warns about arguments to
"snprintf()" when compiling it, as the declaration is an old-style
declaration.
As Ethereal uses function prototypes, there's not much point in making
it possible for its private "snprintf()" to be compiled or used when
function prototypes aren't supported; just get rid of the tests for
__STDC__, so that it's compiled with function prototypes regardless of
whether __STDC__ is defined or not.
While we're at it, have "snprintf()" give it a "__attribute__((format
(printf, 3, 4))))" when compiled by GCC 2.x or later, so that
format/argument checks can be done even on platforms lacking
"snprintf()".
svn path=/trunk/; revision=2689
2000-11-21 21:24:52 +00:00
|
|
|
#if defined(HAVE_STDARG_H)
|
2000-08-11 13:37:21 +00:00
|
|
|
# include <stdarg.h>
|
|
|
|
#else
|
|
|
|
# include <varargs.h>
|
|
|
|
#endif
|
|
|
|
|
2002-07-19 12:59:21 +00:00
|
|
|
/* for size_t */
|
2002-09-12 21:26:51 +00:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
1998-10-13 07:03:37 +00:00
|
|
|
extern int vsnprintf(char *string, size_t length, const char * format,
|
|
|
|
va_list args);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2001-07-22 10:25:50 +00:00
|
|
|
#if __GNUC__ >= 2
|
Some compilers, e.g. Microsoft Visual C++, don't define __STDC__ unless
extensions to ANSI C are disabled if they may cause strictly conforming
programs not to compile, or to work differently if those extensions are
enabled. (Other compilers #define it as 0, e.g. Sun's and, I think,
other AT&T-derived compilers; still others cheerfully define it as 1
even when those extensions are enabled, e.g. GCC.)
As such, checking whether __STDC__ is defined, or is defined as a
non-zero value, isn't the right way to check whether function prototypes
are supported; MSVC++ 6.0 supports them, but, by default, leaves
extensions of the sort described above enabled, and thus doesn't define
__STDC__. This means that the compiler warns about arguments to
"snprintf()" when compiling it, as the declaration is an old-style
declaration.
As Ethereal uses function prototypes, there's not much point in making
it possible for its private "snprintf()" to be compiled or used when
function prototypes aren't supported; just get rid of the tests for
__STDC__, so that it's compiled with function prototypes regardless of
whether __STDC__ is defined or not.
While we're at it, have "snprintf()" give it a "__attribute__((format
(printf, 3, 4))))" when compiled by GCC 2.x or later, so that
format/argument checks can be done even on platforms lacking
"snprintf()".
svn path=/trunk/; revision=2689
2000-11-21 21:24:52 +00:00
|
|
|
extern int snprintf(char *string, size_t length, const char * format, ...)
|
|
|
|
__attribute__((format (printf, 3, 4)));
|
1998-09-16 02:39:15 +00:00
|
|
|
#else
|
Some compilers, e.g. Microsoft Visual C++, don't define __STDC__ unless
extensions to ANSI C are disabled if they may cause strictly conforming
programs not to compile, or to work differently if those extensions are
enabled. (Other compilers #define it as 0, e.g. Sun's and, I think,
other AT&T-derived compilers; still others cheerfully define it as 1
even when those extensions are enabled, e.g. GCC.)
As such, checking whether __STDC__ is defined, or is defined as a
non-zero value, isn't the right way to check whether function prototypes
are supported; MSVC++ 6.0 supports them, but, by default, leaves
extensions of the sort described above enabled, and thus doesn't define
__STDC__. This means that the compiler warns about arguments to
"snprintf()" when compiling it, as the declaration is an old-style
declaration.
As Ethereal uses function prototypes, there's not much point in making
it possible for its private "snprintf()" to be compiled or used when
function prototypes aren't supported; just get rid of the tests for
__STDC__, so that it's compiled with function prototypes regardless of
whether __STDC__ is defined or not.
While we're at it, have "snprintf()" give it a "__attribute__((format
(printf, 3, 4))))" when compiled by GCC 2.x or later, so that
format/argument checks can be done even on platforms lacking
"snprintf()".
svn path=/trunk/; revision=2689
2000-11-21 21:24:52 +00:00
|
|
|
extern int snprintf(char *string, size_t length, const char * format, ...);
|
1998-09-16 02:39:15 +00:00
|
|
|
#endif
|
2000-08-11 13:37:21 +00:00
|
|
|
|
|
|
|
#endif
|