Skip to main content
GameDev.net gamedev.net
🔒 Locked

Runtime Data Type Sizes

Started by EmrldDrgn Jan 16, 2008 at 8:27 PM 2 replies 1k views
Original Post
EmrldDrgn
EmrldDrgn
Is there a way to find out, at runtime, if a given type size (ex. 16 bit integer) exists, typedef it as something and, if it doesn't exist, typedef a template with overloaded functions to take its place? That's really three separate questions, I suppose...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~I program in C++, on MSVC++ '05 Express, and on Windows. Most of my programs are also for windows.
SiCrane
SiCrane
Assuming, you're talking about C++, no. Data type sizes are always determined at compile time.
EmrldDrgn
EmrldDrgn
Yes, I do mean C++. In that case, how does one determine them at compile time, barring a huge header file of #ifdef GCC, #elif MSVC, whatever? I think I saw some code on here to do so awhile back, involving template metaprogramming, but I can't find it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~I program in C++, on MSVC++ '05 Express, and on Windows. Most of my programs are also for windows.
Zao
Zao
For integral types, Boost.Integer (boost/cstdint.hpp) may be suitable, providing portable typedefs for integral types of assorted sizes.
To make it is hell. To fail is divine.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.