75

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?

Piper
  • 1,266
  • 3
  • 15
  • 26
aneuryzm
  • 63,052
  • 100
  • 273
  • 488

3 Answers3

85

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.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
29

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

djechlin
  • 59,258
  • 35
  • 162
  • 290
20

.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:

Objective-C, .m / .mm performance difference?

Community
  • 1
  • 1
Almo
  • 15,538
  • 13
  • 67
  • 95