|
-
November 13th, 2009, 07:53 AM
#8
Re: What is C++ equipvalent of Java Long?
I had a thread about a month ago about which is more important, what a compiler does, or the standards. It was about half and half, if you're like me, you care more about the compiler than standards. I always add these few lines of code at the beginning of any code that I write
Code:
ASSERT(sizeof(char) == 1, "Replace chars with 8 bit primitive");
ASSERT(sizeof(short) == 2, "Replace shorts with 16-bit primitive");
ASSERT(sizeof(int) == 4, "Replace int with 32-bit primitive");
ASSERT(sizeof(long) == 4, "Replace long with 32-bit primitive");
ASSERT(sizeof(long long) == 8, "Replace long long with 64-bit primitive");
ASSERT(sizeof(float) == 4, "Replace float with 32-bit primitive");
ASSERT(sizeof(double) == 8, "Replace double with 64-bit primitive");
ASSERT(sizeof(long double) == 12, "Replace long double with 96-bit primitive");
That way if I port my code to a platform or compiler that has a difference, I can do a quick bulk replace of the primitive that doesn't match up to what I expect 
I have a huge header file full of those things for large projects, especially since I use cross-platform libraries that may be built differently, specifically wxWidgets.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|