1# This Python script creates a full set of C++ C header files that 2# are missing on some platforms. 3# 4# Usage: 5# mkdir cpp_c_headers 6# cd cpp_c_headers 7# python generate_cpp_c_headers.py 8# 9# The files created by this script are in the directory: 10# root/boost/compatibility/cpp_c_headers 11# 12# Supported platforms: 13# Compaq Alpha, RedHat 6.2 Linux, Compaq C++ V6.3 (cxx) 14# Compaq Alpha, Tru64 Unix V5.0, Compaq C++ V6.2 (cxx) 15# Silicon Graphics, IRIX 6.5, MIPSpro Compilers: Version 7.3.1.1m (CC) 16# 17# Support for additional platforms can be added by extending the 18# "defines" Python dictionary below. 19# 20# Python is available at: 21# http://www.python.org/ 22# 23# Copyright (c) 2001 Ralf W. Grosse-Kunstleve. 24# Distributed under the Boost Software License, Version 1.0. (See accompany- 25# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 26# 27# Revision history: 28# 16 Apr 01 moved to boost CVS tree (R.W. Grosse-Kunstleve) 29# 17 Jan 01 Alpha Linux cxx V6.3 support (R.W. Grosse-Kunstleve) 30# 15 Dec 00 posted to boost e-group file upload area (R.W. Grosse-Kunstleve) 31 32# Definition of platform specific exclusion of identifiers. 33defines = { 34 'defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 740': ( 35 'btowc', 'fwide', 'fwprintf', 'fwscanf', 'mbrlen', 'mbrtowc', 36 'mbsinit', 'mbsrtowcs', 'swprintf', 'swscanf', 'towctrans', 'vfwprintf', 37 'vswprintf', 'vwprintf', 'wcrtomb', 'wcsrtombs', 'wctob', 'wctrans', 38 'wctrans_t', 'wmemchr', 'wmemcmp', 'wmemcpy', 'wmemmove', 'wmemset', 39 'wprintf', 'wscanf', 40 ), 41 'defined(__DECCXX_VER) && __DECCXX_VER <= 60290024': ( 42 'fwide', 43 ), 44 'defined(__linux) && defined(__DECCXX_VER) && __DECCXX_VER <= 60390005': ( 45 'getwchar', 'ungetwc', 'fgetwc', 'vfwprintf', 'fgetws', 'vswprintf', 46 'wcsftime', 'fputwc', 'vwprintf', 'fputws', 'fwide', 'putwc', 47 'wprintf', 'fwprintf', 'putwchar', 'wscanf', 'fwscanf', 'swprintf', 48 'getwc', 'swscanf', 49 ), 50} 51 52# The information below was copied directly from the file: 53# ISO+IEC+14882-1998.pdf 54# The exact source of the information is given in the format 55# PDF #, p. #, Table # 56# Where 57# PDF # = page number as shown by the Acrobat Reader 58# p. # = page number printed at the bottom of the page 59# Table # = number printed in caption of table 60hfiles = { 61 'cassert': ( # PDF 378, p. 352, Table 25 62 # Macro: assert 63 ), 64 'cctype': ( # PDF 431, p. 405, Table 45 65 # Functions: 66 'isalnum', 'isdigit', 'isprint', 'isupper', 'tolower', 67 'isalpha', 'isgraph', 'ispunct', 'isxdigit', 'toupper', 68 'iscntrl', 'islower', 'isspace', 69 ), 70 'cerrno': ( # PDF 378, p. 352, Table 26 71 # Macros: EDOM ERANGE errno 72 ), 73 'cfloat': ( # PDF 361, p. 335, Table 17 74 # Macros: DBL_DIG DBL_MIN_EXP FLT_MIN_10_EXP LDBL_MAX_10_EXP 75 # DBL_EPSILON FLT_DIG FLT_MIN_EXP LDBL_MAX_EXP 76 # DBL_MANT_DIG FLT_EPSILON FLT_RADIX LDBL_MIN 77 # DBL_MAX FLT_MANT_DIG FLT_ROUNDS LDBL_MIN_10_EXP 78 # DBL_MAX_10_EXP FLT_MAX LDBL_DIG LDBL_MIN_EXP 79 # DBL_MAX_EXP FLT_MAX_10_EXP LDBL_EPSILON 80 # DBL_MIN FLT_MAX_EXP LDBL_MANT_DIG 81 # DBL_MIN_10_EXP FLT_MIN LDBL_MAX 82 ), 83 #'ciso646': ( 84 #), 85 'climits': ( # PDF 361, p. 335, Table 16 86 # Macros: CHAR_BIT INT_MAX LONG_MIN SCHAR_MIN UCHAR_MAX USHRT_MAX 87 # CHAR_MAX INT_MIN MB_LEN_MAX SHRT_MAX UINT_MAX 88 # CHAR_MIN LONG_MAX SCHAR_MAX SHRT_MIN ULONG_MAX 89 ), 90 'clocale': ( # PDF 483, p. 457, Table 62 91 # Macros: LC_ALL LC_COLLATE LC_CTYPE 92 # LC_MONETARY LC_NUMERIC LC_TIME 93 # NULL 94 # Struct: 95 'lconv', 96 # Functions: 97 'localeconv', 'setlocale', 98 ), 99 'cmath': ( # PDF 622, p. 596, Table 80 100 # Macro: HUGE_VAL 101 # Functions: 102 'acos', 'cos', 'fmod', 'modf', 'tan', 103 'asin', 'cosh', 'frexp', 'pow', 'tanh', 104 'atan', 'exp', 'ldexp', 'sin', 105 'atan2', 'fabs', 'log', 'sinh', 106 'ceil', 'floor', 'log10', 'sqrt', 107 ), 108 'csetjmp': ( # PDF 372, p. 346, Table 20 109 # Macro: setjmp 110 # Type: 111 'jmp_buf', 112 # Function: 113 'longjmp', 114 ), 115 'csignal': ( # PDF 372, p. 346, Table 22 116 # Macros: SIGABRT SIGILL SIGSEGV SIG_DFL 117 # SIG_IGN SIGFPE SIGINT SIGTERM SIG_ERR 118 # Type: 119 'sig_atomic_t', 120 # Functions: 121 'raise', 'signal', 122 ), 123 'cstdarg': ( # PDF 372, p. 346, Table 19 124 # Macros: va_arg va_end va_start 125 # Type: 126 'va_list', 127 ), 128 'cstddef': ( # PDF 353, p. 327, Table 15 129 # Macros: NULL offsetof 130 # Types: 131 'ptrdiff_t', 'size_t', 132 ), 133 'cstdio': ( # PDF 692, p. 666, Table 94 134 # Macros: BUFSIZ FOPEN_MAX SEEK_CUR TMP_MAX _IONBF stdout 135 # EOF L_tmpnam SEEK_END _IOFBF stderr 136 # FILENAME_MAX NULL <cstdio> SEEK_SET _IOLBF stdin 137 # Types: 138 'FILE', 'fpos_t', 'size_t', 139 # Functions: 140 'clearerr', 'fgets', 'fscanf', 'gets', 'rename', 'tmpfile', 141 'fclose', 'fopen', 'fseek', 'perror', 'rewind', 'tmpnam', 142 'feof', 'fprintf', 'fsetpos', 'printf', 'scanf', 'ungetc', 143 'ferror', 'fputc', 'ftell', 'putc', 'setbuf', 'vfprintf', 144 'fflush', 'fputs', 'fwrite', 'putchar', 'setvbuf', 'vprintf', 145 'fgetc', 'fread', 'getc', 'puts', 'sprintf', 'vsprintf', 146 'fgetpos', 'freopen', 'getchar', 'remove', 'sscanf', 147 ), 148 'cstdlib': ( # PDF 362, p. 336, Table 18 149 # Macros: EXIT_FAILURE EXIT_SUCCESS 150 # Functions: 151 'abort', 'atexit', 'exit', 152 # PDF 373, p. 347, Table 23 153 # Functions: 154 'getenv', 'system', 155 # PDF 400, p. 374, Table 33 156 # Functions: 157 'calloc', 'malloc', 158 'free', 'realloc', 159 # PDF 433, p. 417, Table 49 160 # Macros: MB_CUR_MAX 161 # Functions: 162 'atol', 'mblen', 'strtod', 'wctomb', 163 'atof', 'mbstowcs', 'strtol', 'wcstombs', 164 'atoi', 'mbtowc', 'strtoul', 165 # PDF 589, p. 563, Table 78 166 # Functions: 167 'bsearch', 'qsort', 168 # PDF 622, p. 596, Table 81 169 # Macros: RAND_MAX 170 # Types: 171 'div_t', 'ldiv_t', 172 # Functions: 173 'abs', 'labs', 'srand', 174 'div', 'ldiv', 'rand', 175 ), 176 'cstring': ( # PDF 401, p. 375, Table 34 177 # Macro: NULL 178 # Type: size_t 179 # Functions: 180 # 'memchr', 'memcmp', 181 # 'memcpy', 'memmove', 'memset', 182 # PDF 432, p. 406, Table 47 183 # Macro: NULL 184 # Type: 185 'size_t', 186 # Functions: 187 'memchr', 'strcat', 'strcspn', 'strncpy', 'strtok', 188 'memcmp', 'strchr', 'strerror', 'strpbrk', 'strxfrm', 189 'memcpy', 'strcmp', 'strlen', 'strrchr', 190 'memmove', 'strcoll', 'strncat', 'strspn', 191 'memset', 'strcpy', 'strncmp', 'strstr', 192 ), 193 'ctime': ( # PDF 372, p. 346, Table 21 194 # Macros: CLOCKS_PER_SEC 195 # Types: 196 # 'clock_t', 197 # Functions: 198 # 'clock', 199 # PDF 401, p. 375, Table 35 200 # Macros: NULL 201 # Types: 202 'size_t', 'clock_t', 'time_t', 203 # Struct: 204 'tm', 205 # Functions: 206 'asctime', 'clock', 'difftime', 'localtime', 'strftime', 207 'ctime', 'gmtime', 'mktime', 'time', 208 ), 209 'cwchar': ( # PDF 432, p. 406, Table 48 210 # Macros: NULL WCHAR_MAX WCHAR_MIN WEOF 211 # Types: 212 'mbstate_t', 'wint_t', 'size_t', 213 # Functions: 214 'btowc', 'getwchar', 'ungetwc', 'wcscpy', 'wcsrtombs', 'wmemchr', 215 'fgetwc', 'mbrlen', 'vfwprintf', 'wcscspn', 'wcsspn', 'wmemcmp', 216 'fgetws', 'mbrtowc', 'vswprintf', 'wcsftime', 'wcsstr', 'wmemcpy', 217 'fputwc', 'mbsinit', 'vwprintf', 'wcslen', 'wcstod', 'wmemmove', 218 'fputws', 'mbsrtowcs', 'wcrtomb', 'wcsncat', 'wcstok', 'wmemset', 219 'fwide', 'putwc', 'wcscat', 'wcsncmp', 'wcstol', 'wprintf', 220 'fwprintf', 'putwchar', 'wcschr', 'wcsncpy', 'wcstoul', 'wscanf', 221 'fwscanf', 'swprintf', 'wcscmp', 'wcspbrk', 'wcsxfrm', 222 'getwc', 'swscanf', 'wcscoll', 'wcsrchr', 'wctob', 223 ), 224 'cwctype': ( # PDF 432, p. 406, Table 46 225 # Macro: WEOF 226 # Types: 227 'wctrans_t', 'wctype_t', 'wint_t', 228 # Functions: 229 'iswalnum', 'iswctype', 'iswlower', 'iswspace', 'towctrans', 'wctrans', 230 'iswalpha', 'iswdigit', 'iswprint', 'iswupper', 'towlower', 'wctype', 231 'iswcntrl', 'iswgraph', 'iswpunct', 'iswxdigit', 'towupper', 232 ), 233} 234 235if (__name__ == "__main__"): 236 237 import sys, string, time 238 239 now = time.asctime(time.localtime(time.time())) + ' ' + str(time.tzname) 240 241 for hfile in hfiles.keys(): 242 HFILE = string.upper(hfile) 243 f = open(hfile, 'w') 244 sys.stdout = f 245 print '// This file is automatically generated. Do not edit.' 246 print '//', sys.argv 247 print '//', now 248 print 249 print '#ifndef __' + HFILE + '_HEADER' 250 print '#define __' + HFILE + '_HEADER' 251 print '' 252 print '#include <' + hfile[1:] + '.h>' 253 print '' 254 if (len(hfiles[hfile]) > 0): 255 print 'namespace std {' 256 for s in hfiles[hfile]: 257 n_endif = 0 258 for d in defines.keys(): 259 if (s in defines[d]): 260 print '#if !(' + d + ')' 261 n_endif = n_endif + 1 262 print ' using ::' + s + ';' 263 for i in xrange(n_endif): print '#endif' 264 print '}' 265 print '' 266 print '#endif // ' + HFILE + '_HEADER' 267 sys.stdout = sys.__stdout__ 268