limits.h

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

Reply to
Vladimir Vassilevsky
Loading thread data ...

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 to
Arlet

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++.

Your Subject line mentions . 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 . 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 #defines UINT8_MAX, then the platform does have an 8-bit integer type, and it's reachable under the name uint8_t.

Reply to
Hans-Bernhard Bröker

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.