Syntax error before '^' token

℡╲_俬逩灬. 提交于 2019-12-10 10:38:25

问题


I just upgraded core-plot to the latest version in an application that was already running successful plots. I followed the fairly simple instructions to the letter, however I'm getting 20 syntax errors in UIView.h. It seems that I'm not alone, but nobody has of yet posted a solution to the issue.

An example:

This code from UIView.h

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);

gives the compile error "Syntax error before '^' token":

/var/folders/UO/UOZJs7XuF5iROp2HMSTlz++++TI/-Caches-/com.apple.Xcode.501/CompositeSDKs/iphonesimulator-iPhoneSimulator4.0-drysryiarqddqccmfooifrjfbivi/System/Library/Frameworks/UIKit.framework/Headers/UIView.h:250:0 Syntax error before '^' token in /var/folders/UO/UOZJs7XuF5iROp2HMSTlz++++TI/-Caches-/com.apple.Xcode.501/CompositeSDKs/iphonesimulator-iPhoneSimulator4.0-drysryiarqddqccmfooifrjfbivi/System/Library/Frameworks/UIKit.framework/Headers/UIView.h

It believe the solution is related to the build settings. What would cause this error? I'm not familiar with the (^) syntax in Objective-C.


回答1:


The ^ in that context is Apple's implementation of blocks.

My first guess is that you're trying to compile the library with GCC 4.0, which does not recognize the syntax. Perhaps try changing your compiler settings to GCC (or LLVM-GCC) 4.2.

Another compiler-related option that may help is to change the compiler away from GCC entirely. If Clang also has trouble with the compilation, chances are it will show you a better error message.



来源:https://stackoverflow.com/questions/3098611/syntax-error-before-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!