"I have never seen C ++ functions called in C language", "C/C ++ cannot call basic or Pascal functions" is another strange problem, "I don't believe that C, C ++, basic, and Pascal functions can be called blindly, only what you can't think! Since Sister Furong is also famous all over the world, why can't C, C ++, basic, and Pascal functions be called each other? Yes! You can use visual c ++ to write a DLL and call it in Visual Basic and Delphi (the son of Pascal, the son of Object Pascal, alternatively, you can write a DLL in Visual Basic and Delphi to call it in Visual C ++? Let's look at the essence through phenomena. First, let's look at the call conventions of the function (described in Visual C ++): (1) _ stdcall call _ stdcall is Pascal Program The default call method. The parameter uses the stack pressure mode from right to left. The called function clears the stack before returning. Win32 APIs use the _ stdcall call method. This macro definition illustrates the problem: # define winapi _ stdcall is compiled in C mode, and _ stdcall is called by an underscore before the output function name, add the "@" symbol and the number of bytes of the parameter, for example, _ functionname @ number. (2) _ cdecl call _ cdecl is the default call method of C/C ++. The parameter uses the pressure stack mode from right to left, and the memory stack of the transfer parameter is maintained by the caller. _ The functions agreed by cedcl can only be called by C/C ++. Each function that calls it contains Code Therefore, the size of the executable file is larger than that of the _ stdcall function. Since the parameter memory stack of the _ cdecl call method is maintained by the caller, the variable-length parameter function can (or can only) use this call convention. Because visual c ++ uses the _ cdecl call method by default, _ stdcall should be used to call DLL in VC. According to the C compilation method, the _ cdecl call Convention only underlines the output function name, such as _ functionname. (3) _ fastcall: The _ fastcall call is faster. It passes parameters through the internal registers of the CPU. According to the C compilation method, the _ fastcall call Convention adds the "@" symbol before the output function name, followed by the "@" symbol and the number of bytes of the parameter, such as @ functionname @ number.
The keywords _ stdcall, _ cdecl, and _ fastcall can be directly added before the function or set in Visual C ++. When creating a DLL, generally, _ stdcall (Win32 API method) is called, and _ functionname @ number naming rule is used. Therefore, the DLL between different languages can call each other. That is to say, DLL compilation and specific Programming Language It has nothing to do with the compiler. As long as you comply with the DLL development specifications and programming policies and arrange the correct call interface, no matter which programming language the DLL is compiled with, it is universal. To put it bluntly, if there is such an IDE development environment, it can recognize various languages. All languages adopt the same call conventions and naming rules, and functions written in various languages in the software can be called to each other! This ide may never be needed in this world.