• 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: Xcode now defaults to use C99 - so what's C99?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode now defaults to use C99 - so what's C99?


  • Subject: Re: Xcode now defaults to use C99 - so what's C99?
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 30 May 2008 14:07:27 -0700

C99 is very cool; it has many useful features, so don't be put off by the idea of huge specs. Those articles look pretty useful if you haven't already been using C99.

The best features IMHO are:

* Conveniences that C++ has always had:
* variable declarations don't have to go at the beginning of a block (this *really* cleans up code and eliminates a lot of opportunities to use uninitialized variables)
* you can declare the loop variable inside a 'for' loop, i.e.
for (int x=0; x<10; x++) { ... }
* "//" comments; but I think in the real world, all C compilers already supported those
* Variable-length local arrays. This is syntactic sugar for alloca, and can be used to eliminate some temporary allocations. Just be careful not to use this with arbitrarily large arrays, or you can overflow the stack.
size_t size = strlen(str)+1;
char buf[size];
memcpy(buf,str,size);


The improvements to struct initializers are great, too.

And if that's not enough for you, you can set the compiler dialect to "G99" and get a bunch of cool GCC-only extensions. You can read about those in the GCC 4 documentation buried inside the developer docs.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: Xcode now defaults to use C99 - so what's C99?
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >Xcode now defaults to use C99 - so what's C99? (From: David Hoerl <email@hidden>)

  • Prev by Date: Xcode now defaults to use C99 - so what's C99?
  • Next by Date: Re: Xcode now defaults to use C99 - so what's C99?
  • Previous by thread: Xcode now defaults to use C99 - so what's C99?
  • Next by thread: Re: Xcode now defaults to use C99 - so what's C99?
  • Index(es):
    • Date
    • Thread