Skip to content

Instantly share code, notes, and snippets.

@bjhomer
Last active December 15, 2015 16:59
Show Gist options
  • Save bjhomer/5293358 to your computer and use it in GitHub Desktop.
Save bjhomer/5293358 to your computer and use it in GitHub Desktop.
Forward declaration of primitive variables. Turns out it's legal.
#import <Foundation/Foundation.h>
int foo;
int foo;
int foo;
int foo;
int foo = 4;
int main(int argc, const char **argv) {
NSLog(@"foo: %i", foo); // Prints '4'
return 0;
}
@bjhomer
Copy link
Author

bjhomer commented Apr 2, 2013

Apparently these are actually called "tentative declarations", only valid in C. (Not C++.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment