Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
WCSFTIME_WCHAR_T_FMAT.cpp
Go to the documentation of this file.
1// checking for wcsftime() in <wchar.h>
2
3
25#include "config.h"
26
27#if defined (__EDG__) \
28 && !defined (__DECCXX) \
29 && !defined (__HP_aCC) \
30 && !defined (__INTEL_COMPILER) \
31 && !defined (_SGI_COMPILER_VERSION)
32 // disable error #450-D: the type "long long" is nonstandard
33 // when using the vanilla EDG eccp in strict mode (i.e., w/o
34 // long long support)
35# pragma diag_suppress 450
36#endif // EDG eccp on Linux
37
38#include <stddef.h> // for size_t
39#include <stdio.h> // for printf()
40#include <time.h> // for struct tm
41
42#ifndef _RWSTD_NO_WCSFTIME
43# ifndef _RWSTD_NO_WCHAR_H
44# include <wchar.h> // for wcsftime()
45# else // if defined (_RWSTD_NO_WCHAR_H)
46# include <stdlib.h> // for wcsftime()
47# endif // _RWSTD_NO_WCHAR_H
48
49
50#ifndef _RWSTD_NO_NAMESPACE
51
52namespace std { }
53using namespace std;
54
55#endif // _RWSTD_NO_NAMESPACE
56
57
58extern "C" {
59
60typedef size_t (f_w)(wchar_t*, size_t, const wchar_t*, const struct tm*);
61typedef size_t (f_c)(wchar_t*, size_t, const char*, const struct tm*);
62
63}
64
65
66const char* foo (f_w*) { return "const wchar_t*"; }
67
68const char* foo (f_c*) { return "const char*"; }
69
70
71const char* bar ()
72{
73 // 7.16.6 of C95
74 // 7.24.5.1 of C99
75 return foo (&wcsftime);
76}
77
78
79int main ()
80{
81 const char *argtype = bar ();
82 if (*(argtype+6) == 'c') {
83 printf ("#define _RWSTD_NO_WCSFTIME_WCHAR_T_FMAT\n");
84 }
85
86 printf ("#define _RWSTD_WCSFTIME_ARG3_T %s\n", argtype);
87
88 return 0;
89}
90
91#else // if defined (_RWSTD_NO_WCSFTIME)
92
93extern "C" size_t wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
94
95struct tm t;
96
97int main ()
98{
99 wchar_t buf [40] = { 0 };
100
101 // format using a wchar_t format string; if the function takes
102 // a whar_t* argument, it will format as expected, otherwise
103 // it will format at most one character (unless sizeof (char)
104 // == sizeof (wchar_t))
105 size_t n = wcsftime (buf, sizeof buf, L"abc", &t);
106
107 const char *argtype;
108
109 if ( 3 == n
110 && wchar_t ('a') == buf [0]
111 && wchar_t ('b') == buf [1]
112 && wchar_t ('c') == buf [2]
113 && wchar_t ('\0') == buf [3])
114 argtype = "const wchar_t*";
115 else {
116 argtype = "const char*";
117
118 printf ("#define _RWSTD_NO_WCSFTIME_WCHAR_T_FMAT\n");
119
120 }
121
122 printf ("#define _RWSTD_WCSFTIME_ARG3_T %s\n", argtype);
123
124 return 0;
125}
126
127#endif // _RWSTD_NO_WCSFTIME
#define t
Definition 17.names.cpp:136
#define buf
Definition 17.names.cpp:452
#define n
Definition 17.names.cpp:130
IMPORT_C SInt32 printf(const Char *,...)
size_t() f_w(wchar_t *, size_t, const wchar_t *, const struct tm *)
const char * bar()
size_t() f_c(wchar_t *, size_t, const char *, const struct tm *)
Definition json.h:5363
int foo()
Definition HONOR_STD.cpp:30