c++ - Args passing and returning scheme
- Jean-Pierre H. Dumas (18/18) Jan 27 2002 I read carefully (?) the docs and there is one
- Jan Knepper (7/23) Jan 27 2002 Exactly. The prototype has to be correct.
- utheasterlyrobbe (10/36) Dec 23 2025 Yes, you can safely call Microsoft Win32 DLLs from Digital Mars C
I read carefully (?) the docs and there is one puzzling fact about the way DM returns results from C function. (I am still talking about C and Win32) As it is said different from the way MS is doing it, does this really mean that I can *safelly* run a program compiled and linked with DM, dynamically bound to a MS produced dll ? In the doc it is said that it may not work. But then user32.dll, gdi32.dll et al. are giving good results only because they are _pascal ??? If I understand right, with Watcom C, if I compile using register passing conventions (5r) I can still dynamically use MS style dll because they are declared as _cdecl in the .h file. right ? Not same with DM ? Can you technically enlighten me ? Jean-Pierre Dumas
Jan 27 2002
"Jean-Pierre H. Dumas" wrote:I read carefully (?) the docs and there is one puzzling fact about the way DM returns results from C function. (I am still talking about C and Win32) As it is said different from the way MS is doing it, does this really mean that I can *safelly* run a program compiled and linked with DM, dynamically bound to a MS produced dll ?Should be no problem as long as you use the proper prototype.In the doc it is said that it may not work. But then user32.dll, gdi32.dll et al. are giving good results only because they are _pascal ???Exactly. The prototype has to be correct.If I understand right, with Watcom C, if I compile using register passing conventions (5r) I can still dynamically use MS style dll because they are declared as _cdecl in the .h file. right ?Yup!Not same with DM ?Should be the same. There is no -r5 switch though.... Jan
Jan 27 2002
On Sunday, 27 January 2002 at 14:58:57 UTC, Jan Knepper wrote:"Jean-Pierre H. Dumas" wrote:Yes, you can safely call Microsoft Win32 DLLs from Digital Mars C as long as the calling convention and data types match. Win32 APIs use stdcall (sometimes historically called Pascal), not because they are Pascal but because the callee cleans the stack. The warning in the docs refers to ABI mismatches, such as returning structs, long double differences, or C++ name mangling. Like Watcom, Digital Mars works correctly when functions are declared with the proper calling convention in the headers; problems only occur when conventions or data layouts don’t match.I read carefully (?) the docs and there is one puzzling fact about the way DM returns results from C function. (I am still talking about C and Win32) As it is said different from the way MS is doing it, does this really mean that I can *safelly* run a program compiled and linked with DM, dynamically bound to a MS produced dll ?Should be no problem as long as you use the proper prototype.In the doc it is said that it may not work. But then user32.dll, gdi32.dll et al. are giving good results only because they are _pascal ???Exactly. The prototype has to be correct.If I understand right, with Watcom C, if I compile using register passing conventions (5r) I can still dynamically use MS style dll because they are declared as _cdecl in the .h file. right ?Yup!Not same with DM ?Should be the same in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=960157 https://phrazle.co There is no -r5 switch though.... Jan
Dec 23 2025








utheasterlyrobbe <skeincornflower23 gmail.com>