Вопрос по objective-c – autoreleasepool не был объявлен в этой области ошибки

0

Мой проект в XCode 4.2. Этот проект компилируется для обычной отладочной сборки.

Но когда я изменяю тип сборки на профиль (я хочу профилировать использование памяти), я получаю сообщение об ошибке из класса target-c ++ c ++:

/Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:53: error: stray '@' in program /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm: In member function 'void FilterAudioMixer::WriteToBuffer(SInt16*, int)': /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:53: error: 'autoreleasepool' was not declared in this scope /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:53: error: expected ;' before '{' token /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:147: error: expected }' at end of input

строка @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 normal armv7 objective-c++ com.apple.compilers.llvmgcc42 cd /Volumes/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/bin/llvm-gcc-4.2 -x objective-c++ -arch armv7 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -Os -Wreturn-type -Wunused-variable -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -gdwarf-2 -fvisibility=hidden -fvisibility-inlines-hidden -mthumb -miphoneos-version-min=4.0 -iquote /Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.build/Release-iphoneos/Voicer.build/Voicer-generated-files.hmap -I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.build/Release-iphoneos/Voicer.build/Voicer-own-target-headers.hmap -I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.build/Release-iphoneos/Voicer.build/Voicer-all-target-headers.hmap -iquote /Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.build/Release-iphoneos/Voicer.build/Voicer-project-headers.hmap -iquote. -iquotePictures -iquoteCocoaSoundCloudUI -iquoteCocoaSoundCloudAPI -iquoteOHAttributedLabel -iquoteOAuth2Client -iquoteVoicer.xcworkspace -iquoteClasses -iquotehelp -iquoteJSONKit -iquoteShaders -iquoteaudio -iquotePictures/extremeprogrammingpics -iquotePictures/2010 -iquotePictures/Webcam -iquotePictures/2011 -iquotePictures/gui -iquoteCocoaSoundCloudUI/SoundCloud.bundle -iquoteCocoaSoundCloudUI/Sources -iquoteCocoaSoundCloudAPI/Sources "-iquoteOHAttributedLabel/AttributedLabel Example" -iquoteOHAttributedLabel/OHAttributedLabel -iquoteOAuth2Client/Sources -iquoteVoicer.xcworkspace/xcuserdata -iquoteJSONKit/JSONKit -iquoteaudio/CAExtras -iquotePictures/2010/06 -iquotePictures/2010/07 -iquotePictures/2010/08 -iquotePictures/2011/12 -iquotePictures/2011/10 -iquotePictures/2011/11 -iquotePictures/2011/09 -iquotePictures/2011/07 -iquotePictures/2011/08 -iquotePictures/gui/rec -iquotePictures/gui/buttonentity -iquoteCocoaSoundCloudUI/Sources/CocoaAdditions -iquoteCocoaSoundCloudUI/Sources/SoundCloudUI -iquoteCocoaSoundCloudAPI/Sources/SoundCloudAPI "-iquoteOHAttributedLabel/AttributedLabel Example/Classes" -iquoteOAuth2Client/Sources/OAuth2Client -iquoteVoicer.xcworkspace/xcuserdata/mchinen.xcuserdatad -iquotePictures/2010/06/25 -iquotePictures/2010/07/22 -iquotePictures/2010/07/18 -iquotePictures/2010/08/25 -iquotePictures/2010/08/29 -iquotePictures/2010/08/07 -iquotePictures/2010/08/03 -iquotePictures/2011/12/16 -iquotePictures/2011/12/14 -iquotePictures/2011/12/17 -iquotePictures/2011/12/15 -iquotePictures/2011/10/26 -iquotePictures/2011/10/30 -iquotePictures/2011/10/21 -iquotePictures/2011/10/22 -iquotePictures/2011/10/13 -iquotePictures/2011/11/18 -iquotePictures/2011/11/19 -iquotePictures/2011/09/26 -iquotePictures/2011/09/25 -iquotePictures/2011/09/01 -iquotePictures/2011/09/21 -iquotePictures/2011/09/07 -iquotePictures/2011/09/13 -iquotePictures/2011/09/19 -iquotePictures/2011/07/17 -iquotePictures/2011/08/30 -iquotePictures/2011/08/23 -iquotePictures/2011/08/29 -iquoteVoicer.xcworkspace/xcuserdata/mchinen.xcuserdatad/xcdebugger -I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Products/Release-iphoneos/include -I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.build/Release-iphoneos/Voicer.build/DerivedSources/armv7 -I/Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.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/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/PrecompiledHeaders/Filter_Prefix-hbhtwvzcunnlquaijtkwxcnrmocg/Filter_Prefix.pch -c /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm -o /Users/mchinen/Library/Developer/Xcode/DerivedData/Voicer-aebonlzraugcbqarecvubzkhxlfr/Build/Intermediates/Voicer.build/Release-iphoneos/Voicer.build/Objects-normal/armv7/FilterAudioMixer.o

Ваш Ответ

1   ответ
3

gcc-4.2

Что-то в настройках вашей сборки заставляет вас использовать старый компилятор GCC 4.2, который не поддерживает@autoreleasepool, (Более подробное объяснение вэтот ответ.)

В вашей схеме проверьте, какая конфигурация сборки & quot; Профиль & quot; использует. Затем проверьте параметры в вашем проекте и выберите целевую конфигурацию сборки.

Спасибо, что исправили это! Michael Chinen

Похожие вопросы