> It happens quite often that either 64 bit or 8 bit type is not supported
> by compiler/plaform. For the portability, it would be convenient to add
> this support as a class (conditional compilation).
That wouldn't increase portability, but reduce it, because you'd be
limiting yourself to the subset of platforms that has a usable C++
compiler. Remember: no such thing as classes in C++.
> Is there a compiler independent way to know at compile time which types
> are supported and which are not?
Your Subject line mentions <limits.h>. None of the types described in
there are optional, so they're all supported, always, assuming only that
your compiler is not totally broken.
If you're asking about optional types, those would have to be the ones
in <stdint.h>. While you can't test for the typedefs themselves, you
can check the macros that go along with them. E.g., if you find that
<stdint.h> #defines UINT8_MAX, then the platform does have an 8-bit
integer type, and it's reachable under the name uint8_t.
Reply by Arlet●March 12, 20072007-03-12
On Mar 12, 4:37 am, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
wrote:
> It happens quite often that either 64 bit or 8 bit type is not supported
> by compiler/plaform. For the portability, it would be convenient to add
> this support as a class (conditional compilation).
>
> Is there a compiler independent way to know at compile time which types
> are supported and which are not?
There's no way to test if 'typedef's are defined at compile time, at
least in C.
The standard way to solve these problems is to run a configure program
to create target specific makefiles and config.h header file before
you compile your sources. On Unix-like systems you could use something
like GNU autoconf to create those for you. Autoconf comes standard
with tests to probe the supported types on the target system,
basically by providing a script that attempts to compile a series of
small test programs, and seeing if they produce errors or not.
Reply by Vladimir Vassilevsky●March 12, 20072007-03-12
It happens quite often that either 64 bit or 8 bit type is not supported
by compiler/plaform. For the portability, it would be convenient to add
this support as a class (conditional compilation).
Is there a compiler independent way to know at compile time which types
are supported and which are not?
VLV