iOS Issues Summary: 2015-1-9 "ios development". H,.m,.mm,.cpp and other differences

Source: Internet
Author: User
"iOS development". H,.m,.mm,.cpp and other differences

File differences:

. h: Header file. Header files contain declarations of classes, types, functions, and constants.
. m: Source code files. This is a typical source code file extension that can contain objective-c and C code.
. MM: Source code files. Source code files with this extension can contain C + + code in addition to the OBJECTIVE-C and C code. This extension is only used when you really need to use C + + classes or features in your objective-c code.

. cpp: Compile C + + only

You can use the standard # include compilation option when you need to include header files in your source code, but Objective-c provides a better approach. The #import选项和 # Include option is exactly the same, except that it ensures that the same file is included only once. Objective-c's examples and documentation tend to use #import.

The difference between. m and. MM is to tell gcc some parameters to add at compile time. Of course. MM can also be named as. m, but manually add parameters at compile time (trouble)

Common scenarios:

If you have a reference or code containing C + + in your OC code, change this class to. mm;

Example:

Error:./zxing/cpp/core/src/zxing/common/counted.h:21:10: ' iostream ' File not found

When referring to zxing, #import used the iostream, but it is the following class/iphoneos6.1/user/include/c++, it is necessary to change the class name to. mm

Note that the location of the #import or # include in the. mm file is useless if it is in the. h header file.

iOS Issues Summary: 2015-1-9 "ios development". H,.m,.mm,.cpp and other differences

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.