未在此作用域错误中声明自动释放池



我的项目在XCode 4.2中。此项目编译为常规调试生成。

但是,当我将构建类型更改为profile(我想评测内存使用情况)时,我从这个objective-c++c++类中得到了错误:

/Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:53:错误:杂散'@'in program/Volumes/mchinen/sscm/Voicer/FilterAudioMixer.mm:in member函数"void 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 }'

下面的@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只在个人资料下给我带来了问题,为什么?

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

编译/用户/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Inmediates/Voiser.Build/Release iphoneos/Voiserbuild/Objects normal/armv7/FilterAudioMixer.oFilterAudioMixer.mm普通armv7 objective-c++com.apple.compillers.lvmgcc42cd/Volumes/mchinen/scm/Voicersetenv LANG en_US.US-ASCIIsetenv PATH"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.Platforms/Developer//usr/bin:/Applications/Xcode/app/Contents/Developer/usr/bin:/usr/bin:/usr/sbin:/sbin"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2-x objective-c++-arch armv7-fmessage length=0-pipe-Wno trigraph-fpascal字符串-Os-Wreturn类型-Wunused变量-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Develer/SDKs/iPhoneOS5.0.sdk-gdwarf-2-fvisibility=hidden-fvisibility inlines hidden-mthumb-miphoneos版本min=4.0-igote/Users/mchinen/Library/Developer/Xcode/DerivedData/Voiser aebonlzraugcbqarecvubzkhxlfr/Build/Inmediates/Voiser.Build/Release-iphoneos/Voicer.Build/Voiser-generated-files.hmap-I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voiser-aebonlzraugcbqarecvubzkhxlfr/Build/Inmediates/Voiser.Build/Release-iphoneos/Voicer.Build/Voiser-own-target-headers.map-I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voiser-aebonlzraugcbqarecvubzkhxlfr/Build/Inmediates/Voiser.Build/Release-iphoneos/Voicer.Build/Voiser-all-target-headers.hmap-iquote/Users/mchinen/Library/Developer/Xcode/DerivedData/Voiser-aebonlzraugcbqarecvubzkhxlfr/Build/Inmediates/Voiser.Build/Release-iphoneos/Voicer.Build/Voiser-project-headers.hmap-iquote-iqotePictures-iqoteCocoaSoundCloudUI-iqote可可SoundCloudAPI-iqoteOHAttributedLabel-iqoteOAuth2Client-iquoteVoicer.xcworkspace-iqoteClasses-iqotehelp-iqoteJSONKit-iqoteShaders-iqoteaudio-iqotePictures/extremeprogrammingpics-iqutePictures/2010-iqoteImages/Webcam-iqotepictures/2011-iqotePhotos/gui-iqoteCooaSoundcloudUI/SoundCloud.bundle-iqoteCocoaSoundCloudUI/Sources-iqoteCocoa SoundCloudAPI/Sources"-iqoteOHAttributedLabel/AttributedLabel示例"-iqoteOHAttributedLabel/OHAttributedLabel-iqoteOAuth2Client/Sources-quoteVoicer.xcworkspace/xuserdata-iqoteJSONKit/JSONKit-iqoteaudio/CAExtras-iqotePictures/2010/06-iqotePictures/2010/07-iqotePictureS/2010/08-iqotePictures/s2011/12-iqotePictures/2011/10-iqoteImages/2011/11-iqotepictures/2011/09-iqotePictures/2011/07-iqoteImages/2011/08-iqoteImages/gui/rec-iqotePictures/gui/buttonentity-iqoteCocoaSoundCloudUI/Sources/CocoaAdditions-iqotecocoaSoundcloudUI/Sources/SoundCloudUI-iqote可可SoundCloudAPI/Sources/SoundCloudAPI"-iqoteOHAttributedLabel/AttributedLabel Example/Classes"-iqueOAuth2Client/Sources/OAuth2CClient-iquoteVoicer.xcworkspace/xuserdata/mchine.xcuserdatad-iquePictures/2010/06/25-iquePictures/2010/07/22-iquePictures/s010/07/18-iquePictureS/2010/08/25-iqueImages/2010/08/29-iquePictures/2010/08/07-iquePictures/se010/08/03-iquePicture/2011/12/16-iquePictures2011/12/14-iquePictures/2011/12/12/17-12-12/15-iquePictures/2011/10/26-iquePictures/2011/10/30-iqueImages/2011/10/21-iqutePictures/2011.10.22-iquePictureS/2011/10/13-ique Pictures/2011/11/18-iqotePictures/2011/09/26-iqoteImages/2011/09/25-iquepictures/2011/09/11-iquePictures/2011/09/21-iquepictures/2011/09/07-iqueImages/2011/09/13-iquePictures/s2011/09/19-iquePictures/2011/07/17-iquePictures/2011/08/30-iqueImages/2011/08/23-iquePictures.xcworkspace/xuserdata/mchine.xcuserdatad/xcdebugger-I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voiser aebonlzraugcbqarecvubzkhxlfr/Build/Products/Release iphoneos/include-I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Inmediates/Voiser.Build/Release-iphoneos/Voicer.Build/DerivedSources/armv7-I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Inmediates/Voiser.Build/Release-iphoneos/Voicer.Build/DerivedSources-F/Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer aebonlzraugcbqarecvubzkhxlfr/Build/Products/Release iphoneos-DNS_BLOCK_ASSERTIONS=1-include/Users/mchinen/Library/Developer/Xcode/DerivedData/Voiser aebonlzraugcbqarecvubzkhxlfr/Build/Inmediates/PrecompiledHeaders/Filter_Prefix-hbhtwvzcunlquaijtkwxcnrmocg/Filter_Prefix.pch-c/Volumes/mchine/scm/Voicer/FilterAudioMixer.mm/o/Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voiser.Build/Release-iphoneos/Voicer.Build/Objects-normal/arv7/FilterAudioMixer.o

构建日志的重要部分是:

gcc-4.2

您的构建设置中的某些内容导致您使用旧的GCC 4.2编译器,该编译器不支持@autoreleasepool。(在这个答案中有更多的解释。)

在您的方案中,检查"配置文件"正在使用的构建配置。然后,检查该生成配置的项目和目标中的设置。

相关内容

  • 没有找到相关文章

最新更新