• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting the size of type in the preprocessor.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the size of type in the preprocessor.


  • Subject: Re: Getting the size of type in the preprocessor.
  • From: Tim Little <email@hidden>
  • Date: Tue, 2 Sep 2008 23:01:35 -0500

Using that trick I now have everything sorted.  I can test for C99 compatibility and use that preferentially, otherwise I test for MSVC, and then fall back to a set of assumptions that I can effectively assert on at compile time if the sizes are not exactly what i expect.

Thanks all.

Tim

On Sep 2, 2008, at 8:47 PM, Chris Suter wrote:

On Wed, Sep 3, 2008 at 11:31 AM, Steve Checkoway <email@hidden> wrote:
On Tue, Sep 02, 2008 at 07:35:49PM -0500, Tim Little wrote:
> Thanks, I had completely forgotten those existed now.  MS doesn't
> support them in VS, but they have alternatives that are easy to use.

I think the thing to do is use the standard types and for compilers
which don't support standards (basically just VS, right?) define the
types yourself.

On a semi-related note, you can perform compile time checks on sizes of types by doing this:

#define CHECK3(x, line) typedef char check ## line[(x) ? 1 : -1];
#define CHECK2(x, line)  CHECK3(x, line)
#define CHECK(x)   CHECK2(x, __LINE__)

CHECK(sizeof(int) == 4)

You'll get a compiler error if that ever wasn't true.

-- Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Getting the size of type in the preprocessor. (From: Tim Little <email@hidden>)
 >Re: Getting the size of type in the preprocessor. (From: "Clark Cox" <email@hidden>)
 >Re: Getting the size of type in the preprocessor. (From: Tim Little <email@hidden>)
 >Re: Getting the size of type in the preprocessor. (From: Steve Checkoway <email@hidden>)
 >Re: Getting the size of type in the preprocessor. (From: "Chris Suter" <email@hidden>)

  • Prev by Date: preventing symbol reordering in ld64
  • Next by Date: Re: LSOpenCFURLRef() Not Working
  • Previous by thread: Re: Getting the size of type in the preprocessor.
  • Next by thread: help with calling a standard line app from terminal
  • Index(es):
    • Date
    • Thread