Using the FILE type in MinGW and MSVC is a strange problem.

Source: Internet
Author: User

Today, I encountered a strange problem.

Development Environment:

1. Eclipse CDT, using the gcc compiler and function library of MinGW

2. Visual Studio 2008

Problem description:

A dll is compiled using gcc in eclipse cdt. This dll contains a function that receives the FILE * parameter.

Thefunc (FILE *

After being compiled into a dll, you can use the thefunc function in the dll in MSVC to compile the SDK. However, when running the SDK, the memory cannot be written.

The following three calls have the same problem:

1.

# Include <stdio. h>

2.

# Include <stdio. h>

3.

# Include <stdio. h> * f = fopen (,

After repeated attempts, we found that:

1. dll and calling programs are compiled using gcc and can run normally.

2. The dll and the calling program are both compiled using vs2008 and can also run normally.

3. The dll is compiled with gcc, and the calling program is compiled with vs2008. The compilation is successful, but the memory is written.

4. Currently, most of the other functions in the dll compiled using gcc can be used normally in vs2008, but this FILE * type parameter may be involved.

Question:

The test program has been very simplified and can be ruled out as a logic issue in the code. But why is this gcc compiled dll available? Most functions can be used normally in vs2008, however, a FILE * type parameter may cause problems. Why? Is there a solution? Ask for advice on passing prawns.

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.