首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:@令牌之前的语法错误(为什么?)

错误:@令牌之前的语法错误(为什么?)
EN

Stack Overflow用户
提问于 2009-08-04 23:35:53
回答 3查看 1.4K关注 0票数 0

我在我的混和项目中包含了iPhone sqlite代码,并删除了对iPhone sqlite框架的引用。

我的主要目标编译得很好。

我有第二个用google框架进行单元测试的目标。在编译时,我得到:

错误:@令牌之前的语法错误

我不明白为什么。我已经将这两个项目设置为sdk 2。

更新:我包括到sqlite代码& google的链接。我必须补充说,在我添加sqlite代码之前,目标编译的时间是很好的。我不会发布示例代码,因为我得到了1263个错误- -所以我在所有文件-中都出现了错误,但这是一个示例跟踪:

代码语言:javascript
复制
@class NSString, Protocol; <== ERROR HERE

回溯:

代码语言:javascript
复制
        cd /Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone
        setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 -x c-header -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -iquote /Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/Testing-generated-files.hmap -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/Testing-own-target-headers.hmap -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/Testing-all-target-headers.hmap -iquote /Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/Testing-project-headers.hmap -F/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/Debug-iphonesimulator -F/Volumes/CrashReporter-1.0-rc2/CrashReporter-iPhone -F/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/Debug-iphonesimulator/include -I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/usr/include/libxml2 "-I/Developer/RemObjects Software/Source" -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/DerivedSources/i386 -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/DerivedSources -c /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h -o /var/folders/EA/EAmC8fuyElexZfnpnjdyr++++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/UIKit-dqqtnrciylhdtjbmyglpcezxchmz/UIKit.h.gch
    In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12,
                     from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:8,
                     from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9:
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:120: 
error: syntax error before '@' token
EN

Stack Overflow用户

发布于 2012-03-21 04:47:59

gcc命令行正在将.h文件编译为.gch文件。

代码语言:javascript
复制
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0
    # ...
    -x c-header -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs # ...
    # ...
    # THE INPUT FILE:
    /Developer/Platforms/iPhoneSimulator.platform/Developer/
      SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Framework/
      UIKit.framework/Headers/UIKit.h
    # THE OUTPUT FILE:
    -o /var/folders/EA/EAmC8fuyElexZfnpnjdyr++++TI/
       -Caches-/com.apple.Xcode.501/
       SharedPrecompiledHeaders/UIKit-dqqtnrciylhdtjbmyglpcezxchmz/UIKit.h.gch

也就是说,将UIKit.h转换为UIKit.h.gch:将头文件转换为“预编译的”头文件,该头文件可以更快地包含,因为它是标记化的形式。

看起来编译器不知道它应该预编译一个标头;它不知怎么配置不正确,只是把它当作要实际编译的代码,并且因为代码是目标C而窒息。

票数 0
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1230450

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档