zyl910
I used to let VC + + and other compilers support C99 integer type, then wrote the C99int Library to Intelligent processing (http://www.cnblogs.com/zyl910/p/c99int_v102.html). Now in order to compatible with the Turbo C + + 3 and other DOS compiler, made a major change, no longer suitable for the old name, so the use of Zlstdint this new name.
I. Introduction of Usage
The usage is simple--put z_stdint.h, z_inttyp.h these 2 files into your project, you can use the C99 integer type and related macros normally.
Sample code--
#define__stdc_limit_macros#define__stdc_constant_macros#define__stdc_format_macros#include<stdio.h>#include"z_stdint.h"#include"Z_inttyp.h"///Main.intMainintargcChar*argv[]) {uint8_t i8= (uint8_t) Int8_c (-1); uint16_t i16= (uint16_t) Int16_c (-1); uint32_t i32= (uint32_t) Int32_c (-1); #ifdef Int64_max uint64_t i64= (uint64_t) Int64_c (-1);#endif#ifdef Int64_max printf ("stdint:\t%"PRIu8", %"PRIu16", %"PRIu32", %"PRIu64"\ n", i8, i16, I32, i64);#elseprintf ("stdint:\t%"PRIu8", %"PRIu16", %"PRIu32"\ n", i8, i16, i32);#endif return 0;}
Because the old compiler does not support a 64-bit integer type, it is supported based on the INT64_MAX macro.
Ii. Details of changes
In order to support the Turbo C + + 3 and other DOS compiler, so carefully designed the header file name, so that it conforms to the 8.3 file name naming rules. File name correspondence is---
Z_stdint.h: Corresponds to the "stdint.h" in the C99 standard.
Z_inttyp.h: Corresponds to the "Inttypes.h" in the C99 standard.
The prefix "Z_" indicates that it is used to be compatible with header files in the C standard, and the subsequent 6 letters are abbreviations for the corresponding header files.
Since older compilers such as the Turbo C + + 3 do not support 64-bit integer types, Zlstdint also adjusts--if the compiler does not support a 64-bit integer type, then the standard 64-bit integer type (int64_t, uint64_t, int_least64_t ...) is not defined. ) and the corresponding macro (Int64_max, Uint64_max ... ), and the maximum integer type, such as intmax_t, is limited to 32 bits. To detect this, Zlstdint provides a z_stdint_intmax_bit (number of bits in the intmax_t type) macro.
Given that the code that automatically identifies the compiler is likely to be misjudged, these configuration macros are provided-
Z_stdint_h_usesys: Whether you are using a compiler-provided stdint.h.
Z_inttyp_h_usesys: Whether you are using a compiler-provided inttypes.h.
Third, test results
The following compilers have been tested--
* Virtual C + +: 6, 7.1 (2003), 8 (2005), 9 (2008), 10 (2010), 11 (2012), 12 (2013).
* Turbo C + +: Turbo C + + 3, Borland C + + 3.1, C + + Builder 6, C + + Builder XE3.
* GCC (Linux): 4.7.0~4.8.2 (Fedora 17~20), 4.6.3~4.8.2 (Ubuntu 12.04~14.04).
* GCC (MinGW): 4.6.2 (MinGW (20120426)), 4.7.1~4.9.2 (TDM-GCC (MINGW-W64)).
* LLVM gcc:4.2 (Mac OS X Lion 10.7.4), 4.2.1 (Mac OS X Mountain lion 10.8.3).
For example, in the DOS of the Turbo C + + 3 compiled by--
Reference documents
~~~~~~~~
"ISO/IEC 9899:1999 (C99)". iso/iec,1999. Www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
"C99 standard". Yourtommy. http://blog.csdn.net/yourtommy/article/details/7495033
The [c/C + +] shows the predetermined macros (C11 Standard, c++11 Standard, VC, BCB, Intel, GCC) of various C/+ + compilers. Http://www.cnblogs.com/zyl910/archive/2012/08/02/printmacro.html
"[C] let VC, BCB support C99 integer type (stdint.h, inttypes.h) (GCC compatible)". Http://www.cnblogs.com/zyl910/archive/2012/08/08/c99int.html
"[C] let the VC support C99 integer type V1.01. Avoid including directory issues, rename auto_stdint.h, Auto_inttypes.h (test pass under compilers such as VC6 to VC2012, GCC, BCB, etc.). Http://www.cnblogs.com/zyl910/archive/2013/01/10/c99int_v101.html
The [C] C99int (Let the VC and other compilers automatically compatible with C99 integer type) V1.02. Source is hosted on GitHub, add cmake compile configuration file, use Doxygen specification note. Http://www.cnblogs.com/zyl910/p/c99int_v102.html
Source code Download--
Https://github.com/zyl910/zlstdint
[C] Zlstdint (make VC, TC and other compilers automatically compatible with C99 integer type) V1.0. Support for compilers in Turbo C + + 3 and other DOS