C Language: what does the .mm extension stand for?

Objective CObjective C++

Objective C Problem Overview


A project with some Objective-C has a few C classes with the implementation files having a .mm extension.

file.h
file.mm

What does the .mm mean? Shouldn't it just be .m?

Objective C Solutions


Solution 1 - Objective C

The extension .mm is the extension for the C++ compilation unit expected by the Objective-C compiler, while the .m extension is the extension for the C compilation unit expected by the Objective-C compiler.

That's assuming you don't use a compiler flag to override the file extension, as this gentleman has done.

Solution 2 - Objective C

Objective C++, mixes C++ and Objective C. http://en.wikipedia.org/wiki/Objective-C#Objective-C.2B.2B

Solution 3 - Objective C

.mm files are like .cpp files to the Objective-C compiler. They activate the C++ compiler instead of the C compiler.

The following question on performance has additional useful information:

https://stackoverflow.com/questions/2317868/objective-c-m-mm-performance-difference

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionaneuryzmView Question on Stackoverflow
Solution 1 - Objective CEdwin BuckView Answer on Stackoverflow
Solution 2 - Objective CdjechlinView Answer on Stackoverflow
Solution 3 - Objective CAlmoView Answer on Stackoverflow