# Simple application of Pragma once and _ msc_ver

Source: Internet
Author: User
Document directory
  • _ Msc_ver

# Pragma once

You only need to add this command at the beginning of the header file to ensure that the header file is compiled once. This command is actually available in vc6, but it is not widely used in consideration of compatibility. # Pragma once is related to compilation, that is, it can be used in this compilation system, but not necessarily in other compilation systems, that is, it has poor portability, but now, basically every compiler has this definition. # Ifndef, # define, # endif, which is related to the C ++ language. This is a macro definition in the C ++ language. Using the macro definition, you can avoid multiple compilation of files. Therefore, it is effective in all compilers that support the C ++ language. If the program to be written is cross-platform, it is best to use this method.

_ Msc_ver

Define the version of the compiler. The following are the _ msc_ver values of some compiler versions (see references 2 in extended reading)

Ms vc ++ 10.0 _ msc_ver = 1600

Ms vc ++ 9.0 _ msc_ver = 1500

Ms vc ++ 8.0 _ msc_ver = 1400

Ms vc ++ 7.1 _ msc_ver = 1310

Ms vc ++ 7.0 _ msc_ver = 1300

Ms vc ++ 6.0 _ msc_ver = 1200

Ms vc ++ 5.0 _ msc_ver = 1100

Among them, Ms VC ++ 10.0 is Visual C ++ 2010, ms vc ++ 9.0 is Visual C ++ 2008, ms vc ++ 8.0 is Visual C ++ 2005. For the relationship between version names, see the reference 1 link in extended reading.

Adding the _ msc_ver macro to the program allows the compiler to selectively compile a program based on the compiler version. For example, the Lib file generated by a version compiler may not be called by the compiler of another version. When developing an application, put the Lib file generated by multiple version compilers in the Lib call library of this program. When the _ msc_ver macro is added to the program, the compiler can automatically select the Lib library version that can be linked according to its version when calling the program.

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.