Tom St Denis wrote:
Peter Nilsson wrote:
One alternative is to check for SIZE_MAX in <limits.h>. A conforming
C90
implementation cannot define that macro; a C99 implementation must.
Since it sounds like the OP is really checking for whcar_t, the
WCHAR_MAX
would distinguish C94/95/99 implementations from C90 ones.
Thanks to both, testing for WCHAR_MAX is probably the simplest. For my
purposes all I'm doing is encoding/decoding ASN.1 so all the string
routines [e.g., wcstrcmp or whatever] don't matter to me. Ideally I'd
like to use wchar_t for people with C99 platforms so they don't have to
cast or convert to the proper type to use the C functions for wchar
strings.
Just a follow up ... what I have so far ... :-(
#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L ||
defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED))
&& !defined(LTC_NO_WCHAR)
#include <wchar.h>
#else
typedef ulong32 wchar_t;
#endif
[excuse the wrapped lines...]
It seems that gcc will not natively define __STDC_VERSION [or to match
the restraint]. Also WCHAR_MAX is only defined if you explicitly
include wchar.h ... (my guess is you need to force --std=c99 for that
to show up...)
_WCHAR_T is defined through some standard glibc headers and
_WCHAR_T_DEFINED through some VC6 headers....
Tom