views:

438

answers:

3

Is there any reason why you shouldn't use the "-std=c99" flag for compiling Objective-C programs on Mac? The one feature in C99 that I really like is the ability to declare variables anywhere in code, rather than just at the top of methods, but does this flag causes any problems or create incompatibilities for iPhone or Cocoa apps?

+2  A: 

I've tried it myself on a small iPhone app, and it works. I've seen no problems with it.

Derek Ledbetter
Cool, thanks for trying it
Andy White
+4  A: 

Compiled C99 binary code is binary-compatible with older C variants. The only downside is if you have to share code with other projects that aren't C99 (or GNU99).

The same applies to Objective-C

rpetrich
+1  A: 

A good way to do this if your project settings aren't letting you do it is to add a User-Defined setting. To do so:

  • Open your "Project -> Edit Project Settings" menu item.

  • at the bottom left, select "Add User-Defined Setting" from the dropdown menu

  • Replace the left side text "New Setting" with GCC_C_LANGUAGE_STANDARD

  • add the text "c99" to the right side of the line

  • clean your target & rebuild!

Evan Robinson