Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Basic C function ends up with error when trying to compile + example

Hello Guys,


Gotta problem here with normal function in c:


My configuration:


OS 10.8

Xcode 5.0.2


Code:


void printMessage (void) {
NSLog(@"Test");
}
printMessage();


Note that this ends up with error:


ProcessPCH /Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqrxz fkcygoghf/Build/Intermediates/PrecompiledHeaders/test-Prefix-bjoindrfwbhakucgefd kktxqsafj/test-Prefix.pch.pch test/test-Prefix.pch normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler

cd /Users/cistyprofil/Documents/CA/test

setenv LANG en_US.US-ASCII

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ usr/bin/clang -x objective-c-header -arch i386 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/ SDKs/MacOSX10.8.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mmacosx-version-min=10.8 -g -Wno-sign-conversion -iquote /Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqrxz fkcygoghf/Build/Intermediates/test.build/Debug/test.build/test-generated-files.h map -I/Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqr xzfkcygoghf/Build/Intermediates/test.build/Debug/test.build/test-own-target-head ers.hmap -I/Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqr xzfkcygoghf/Build/Intermediates/test.build/Debug/test.build/test-all-target-head ers.hmap -iquote /Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqrxz fkcygoghf/Build/Intermediates/test.build/Debug/test.build/test-project-headers.h map -I/Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqr xzfkcygoghf/Build/Products/Debug/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchai n/usr/include -I/Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqr xzfkcygoghf/Build/Intermediates/test.build/Debug/test.build/DerivedSources/i386 -I/Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqr xzfkcygoghf/Build/Intermediates/test.build/Debug/test.build/DerivedSources -F/Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqr xzfkcygoghf/Build/Products/Debug --serialize-diagnostics /Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqrxz fkcygoghf/Build/Intermediates/PrecompiledHeaders/test-Prefix-bjoindrfwbhakucgefd kktxqsafj/test-Prefix.pch.dia -MMD -MT dependencies -MF /Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqrxz fkcygoghf/Build/Intermediates/PrecompiledHeaders/test-Prefix-bjoindrfwbhakucgefd kktxqsafj/test-Prefix.pch.d -c /Users/cistyprofil/Documents/CA/test/test/test-Prefix.pch -o /Users/cistyprofil/Library/Developer/Xcode/DerivedData/test-butpvmdeqxfberfqrxz fkcygoghf/Build/Intermediates/PrecompiledHeaders/test-Prefix-bjoindrfwbhakucgefd kktxqsafj/test-Prefix.pch.pch


error: -fobjc-arc is not supported on platforms using the legacy runtime

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ usr/bin/clang failed with exit code 1


Please advise.

MacBook Pro (15-inch Late 2008), OS X Mountain Lion (10.8.5)

Posted on Jan 21, 2014 2:07 PM

9 replies

Jan 21, 2014 8:30 PM in response to Community User

Hello,


sorry, the whole code is:


#import <Foundation/Foundation.h>


int main(int argc, const char * argv[])

{


@autoreleasepool {

void printMessage (void) {

NSLog(@"Test");

}

printMessage();

}

return 0;

}


I have created command line tool in xcode for mac os.


I have used the tutorial below to do that. ( just have put the function definition up, otherwise, I will get error message, that this is not ok with c99.)



http://www.youtube.com/watch?v=bDwSTAe7Bzo&feature=c4-overview-vl&list=PLD05642A D0D531E1B


To the ARC, it is on by default on Xcode5. If I would like to make it running with ARC, would the code be any different. If yes, can you please post example?


Thanks.

Jan 22, 2014 7:25 AM in response to etresoft

ok, got it, nested functions do not work.


Regarding that book you recommend, I guess it is:


http://zanasi.chem.unisa.it/download/C.pdf


I was thinking about what is the best way to learn Objective C and it seems that it is the best to simply start with the C in cli then move to objective c in cli and then move to Cocoa.


Guys, If you would suggest different approach, please let me know.

Basic C function ends up with error when trying to compile + example

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.