An experiment was conducted to compile C files in the MFC project.

Source: Internet
Author: User

It is mainly used to verify the content of errors reported by VC ++ 6.0 in various situations.

For the tutorial background, see:

(1) Create an MFC Appwizard Project

(2) content in tstextn. h

(3) content in tstextn. c

(4) Call functions in the C file in a CPP File

(5) Remove the pre-compiled header of tstextn. C.

The first step is not to define the type of the upper-case bool (Note: In MFC, the upper-case bool is defined as the int type)

Because the C language is used for compilation, the program reports the following error: we can see that the compiler does not know the upper-case bool in extern "C.

In tstextn. H, open the bool type definition and you can use it. Because tstextn. H is included in the. cpp file, if the type of the large bool is defined as a type other than int, such as char, at this time. It will cause confusion of the large bool type in MFC. In this experiment, the type of the big bool in tstextn. h and tstextn. C is defined as Int.

 

If # include "stdafx. H" is written at the beginning of tstextn. H (this is a common method to solve C ++/C Mixed encoding in VC), the following error is reported:

Compiling...
Tstextn. c
D:/program files/Microsoft Visual Studio/vc98/mfc/include/afx. H (15 ):

Fatal error c1189: # error: MFC requires C ++ compilation (Use A. cpp suffix)
Error executing cl.exe.
Creating browse info file...
BSCMAKE: Error bk1506: cannot open file './debug/tstextn. SBR': no such file or directory
Error executing bscmake.exe.

It is proved that when # include "stdafx. H" is added, you must change the file suffix to *. cpp.

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.