When compiling Objective-C from the command line (gcc), what are some good flags to use? Many of the standard C flags (-Wall, -ansi, etc) don’t play well with Objective-C.
I currently just use -lobjc and -frameworkwith various frameworks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
-Wallworks perfectly fine with Objective-C.The thing to do is build an Objective-C file with Xcode and have a look at the build transcript. I’ve just done that and here are some highlights:
-x objective-cI guess that means “compile as Objective-C”, probably important-arch x86_64build for a particular CPU architecture-std=gnu99build for C99 + GNU extensions (actually surprised me, I thought Xcode used -std=c99).-isysroot ....specifies the location of the SDK.-mmacosx-version-min=10.6I am compiling for 10.6 and up-fobjc-gc-onlythis file was intended to be used with garbage collection and won’t work without it, so I compile for GC only.-Wallthe obvious.If you are compiling from the command line, it’s probably a good idea to set the option to treat warnings as errors. I don’t from within Xcode because the build results window remembers the uncleared warnings from previous builds.