autoreleasepool并没有在此范围内声明的错误(autoreleasepool was n

2019-07-29 07:22发布

我的项目是在XCode中4.2。 该项目为编译定期调试版本。

但是,当我改变构建类型来分析(我想配置内存使用),我从中得到的Objective-C ++ C ++类的错误:

/Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:53:错误:在程序/Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm杂散 '@':在成员函数“无效FilterAudioMixer :: WriteToBuffer(SInt16 *,INT ) ':/Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:53:错误: 'autoreleasepool':错误:未在此范围/Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:53宣布预期;' before '{' token /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:147: error: expected ;' before '{' token /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:147: error: expected }”在输入的端

下面@autoreleasepool线是线53:

void FilterAudioMixer::WriteToBuffer(SInt16* buffer, int nb_samps)
{
   @autoreleasepool {
      //do a per element lock (todo)
      pthread_mutex_lock(&playlist_lock);
      FilterSound *snd;

      size_t count = playlist.size();
      for (size_t i = 0; i < count; i++) {
         snd = playlist[i];
         [snd writeToBuffer:buffer samples:nb_samps];
      }
      pthread_mutex_unlock(&playlist_lock);

      if (m_mute) {
         memset(buffer, 0, sizeof(SInt16) * 2 * nb_samps);
      }
   }
}

这样看来,@autoreleasepool是给我的问题只有在个人主页上,这是为什么?

为了完整起见,这里是从构建结果窗口中的编译行:

CompileC /Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.build/Release-iphoneos/Voicer.build/Objects-normal/armv7/FilterAudioMixer.o FilterAudioMixer.mm正常的ARMv7 objective- C ++ com.apple.compilers.llvmgcc42坎德拉/容量/ mchinen / SCM / Voicer SETENV LANG en_US.US-ASCII SETENV PATH“/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin: /Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin” /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/ USR /斌/ LLVM-GCC-4.2 -x目标c ++ -arch的ARMv7 -fmessage长度= 0 -pipe -Wno-三合字母-fpascal串-Wreturn -Os型-Wunused可变-isysroot /应用/ Xcode中。应用程序/内容/开发商/平台/ iPhoneOS.platform /开发商/软件开发工具包/ iPhoneOS5.0.sdk -gdwarf-2 -fvisibility =隐藏-fvisibility-内联隐藏-mthumb -miphoneos版本分钟= 4.0 -iquote /用户/ mchinen /库/开发商/ Xcode中/导出 DDATA / Voicer-aebonlzraugcbqarecvubzkhxlfr /编译/中间体/ Voicer.build /释放-的iPhoneOS / Voicer.build / Voicer产生-files.hmap -I /用户/ mchinen /库/开发商/ Xcode中/ DerivedData / Voicer-aebonlzraugcbqarecvubzkhxlfr /编译/中间体/ Voicer.build /释放-的iPhoneOS / Voicer.build / Voicer-自己的目标 - headers.hmap -I /用户/ mchinen /库/开发商/ Xcode中/ DerivedData / Voicer-aebonlzraugcbqarecvubzkhxlfr /编译/中间体/ Voicer.build /释放的iPhoneOS / Voicer.build / Voicer-所有目标headers.hmap -iquote /Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.build/Release-iphoneos/Voicer。建立/ Voicer项目 - headers.hmap -iquote。 -iquotePictures -iquoteCocoaSoundCloudUI -iquoteCocoaSoundCloudAPI -iquoteOHAttributedLabel -iquoteOAuth2Client -iquoteVoicer.xcworkspace -iquoteClasses -iquotehelp -iquoteJSONKit -iquoteShaders -iquoteaudio -iquotePictures / extremeprogrammingpics -iquotePictures / 2010 -iquotePictures /网络摄像头-iquotePictures / 2011 -iquotePictures / GUI -iquoteCocoaSoundCloudUI / SoundCloud.bundle -iquoteCocoaSoundCloudUI /源头-iquoteCocoaSoundCloudAPI /源 “-iquoteOHAttributedLabel / AttributedLabel实施例” -iquoteOHAttributedLabel / OHAttributedLabel -iquoteOAuth2Client /源头-iquoteVoicer.xcworkspace / xcuserdata -iquoteJSONKit / JSONKit -iquoteaudio / CAExtras -iquotePictures / 2010/06 -iquotePictures / 2010/07 - iquotePictures / 2010/08 -iquotePictures /十二分之二千零一十一-iquotePictures /十分之二千零十一-iquotePictures /十一分之二千零十一-iquotePictures / 2011/09 -iquotePictures / 2011/07 -iquotePictures / 2011/08 -iquotePictures / GUI / REC -iquotePictures / GUI / buttonentity -iquoteCocoaSoundCloudUI /来源/ CocoaAdditions -iquoteCocoaSoundCloudUI /资源/ SoundCloudUI -iquoteCocoaSoundCloudAPI /来源/ SoundCloudAPI “-iquoteOHAttributedLabel / AttributedLabel实施例/类” -iquoteOAuth2Client /来源/ OAuth2Client -iquoteVoicer.xcworkspace / xcuserdata / mchinen.xcuserdatad -iquotePictures / 2010/6月25日-iquotePictures / 2010/7月22日-iquotePictures / 2010/7月18日-iquotePictures / 2010/8月25日-iquotePictures / 2010/8月29日-iquotePictures / 2010/08/07 -iquotePictures / 2010/8月3日-iquotePictures / 2011 /一十六分之一十二-iquotePictures / 2011 /一十四分之一十二-iquotePictures / 2011 /17分之12-iquotePictures / 2011 /一十五分之一十二-iquotePictures / 2011 /26分之10-iquotePictures / 2011 /30分之10-iquotePictures / 2011 /21分之10-iquotePictures /十分之二千○一十一/ 22 -iquotePictures / 2011/10/13 -iquotePictures / 2011 /一十八分之一十一-iquotePictures / 2011 /一十九分之一十一-iquotePictures / 2011/9月26日-iquotePictures / 2011/9月25日-iquotePictures / 2011/9月1日-iquotePictures / 2011/9月21日-iquotePictures / 2011/09/07 -iquotePictures / 2011/9月13日-iquotePictures / 2011/9月19日-iquotePictures / 2011/7月17日-iquotePictures / 2011/8月30日-iquotePictures / 2011/8月23日-iquotePictures / 2011/8月29日 -iquoteVoicer.xcworkspace / xcuserdata / mchinen.xcuserdatad / xcdebugger -I /用户/ mchinen /库/开发商/ Xcode中/ DerivedData / Voicer-aebonlzraugcbqarecvubzkhxlfr /编译/产品/释放-的iPhoneOS /包括-I /用户/ mchinen /库/开发人员/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.build/Release-iphoneos/Voicer.build/DerivedSources/armv7 -I /用户/ mchinen /库/开发商/ Xcode中/ DerivedData / Voicer-aebonlzraugcbqarecvubzkhxlfr /编译/中间体/Voicer.build/Release-iphoneos/Voicer.build/DerivedSources -F /用户/ mchinen /库/开发商/ Xcode中/ DerivedData / Voicer-aebonlzraugcbqarecvubzkhxlfr /编译/产品/释放-的iPhoneOS -DNS_BLOCK_ASSERTIONS = 1 -include /用户/ mchinen /Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/PrecompiledHeaders/Filter_Prefix-hbhtwvzcunnlquaijtkwxcnrmocg/Filter_Prefix.pch -c /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm -o /用户/ mchinen /库/开发人员/ Xcode中/ DerivedData / Voicer-aebonlzra ugcbqarecvubzkhxlfr /生成/中间体/ Voicer.build /释放-的iPhoneOS / Voicer.build /对象 - 正常/ ARMv7的/ FilterAudioMixer.o

Answer 1:

该生成日志的重要组成部分是:

GCC-4.2

东西在您的构建设置导致您使用旧的GCC 4.2编译,不支持@autoreleasepool 。 (在更多解释这个答案 。)

在你的计划,检查哪些生成配置“配置文件”使用。 然后,检查设置在你的项目和目标为构建配置。



文章来源: autoreleasepool was not declared in this scope error