问题
My project is in XCode 4.2. This project compiles for a regular debug build.
But when I change the build type to profile (I want to profile memory usage), I get the error from this objective-c++ c++ class:
/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
the @autoreleasepool line below is line 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);
}
}
}
It would appear that @autoreleasepool is giving me problems only under profile, why is that?
For completeness, here is the compile line from the build result window:
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:
The important part of that build log is:
gcc-4.2
Something in your build settings is causing you to use the old GCC 4.2 compiler, which doesn't support @autoreleasepool
. (More explanation in this answer.)
In your scheme, check what build configuration "Profile" is using. Then, check the settings in your project and target for that build configuration.
来源:https://stackoverflow.com/questions/10468901/autoreleasepool-was-not-declared-in-this-scope-error