Search code examples
c++objective-ccxcodeopenal

Weird syntax error in Xcode based on file type


I have a C header with this function:

OSStatus MyGetDataFromExtAudioRef(ExtAudioFileRef ext_file_ref, const AudioStreamBasicDescription* restrict output_format, ALsizei max_buffer_size, void** data_buffer, ALsizei* data_buffer_size, ALenum* al_format, ALsizei* sample_rate);

I can #include this header in an Objective-C file and compile fine.

If I change that same Objective-C file to a .mm suffix rather than .m and verify that it is now identified as Objective-C++ source, I get a compiler error that says Expected ')' on the line above. While not clear, it seems to be placing the source of the error on the word output_format parameter.

There is nothing in the above function that appears to be bad syntax, with regards to parenthesis, and I can't understand why this one change should make any difference.

Does anything jump out at anyone here?


Solution

  • Simple, the restrict keyword isn't part of the C++ standard, so the C++ compiler (that is used to compile Objective-C++ code) doesn't recognize it.