DotGNU Portable.NET - Bugs: bug #20354, Problems with pinvoke declared to...
You are not allowed to post comments on this tracker with your current authentication level.
bug #20354: Problems with pinvoke declared to return struct
| Submitter: | Radek Polak <radekp> | ||
| Submitted: | Thu 05 Jul 2007 07:28:48 AM UTC | ||
| Category: | None | Severity: | 3 - Normal |
| Item Group: | None | Status: | Invalid |
| Privacy: | Public | Assigned to: | None |
| Open/Closed: | Closed | ||
|
Thu 05 Jul 2007 12:15:55 PM UTC, comment #1: |
Radek Polak <radekp> |
|
Thu 05 Jul 2007 07:28:48 AM UTC, original submission:
Hi,
|
Radek Polak <radekp> |
Attached Files
Depends on the following items: None found
Items that depend on this one: None found
Carbon-Copy List
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

It seems that the code works only on windows. On linux (even with mono) it fails because of different calling conventions.
[13:47] <klausT|work> the pinvoked function doesn't return a struct
[13:51] <radekp> yep
[13:51] <klausT|work> does the function return an int or a boolean?
[13:51] <radekp> int
[13:52] <klausT|work> so you declared the return type in C# as int too?
[13:52] <radekp> if i declare return type as int it works
[13:53] <radekp> but if i declare it with return type as struct it fails
[13:53] <klausT|work> yes, of course it fails
[13:53] <radekp> on .NET it works on pnet no
[13:53] <klausT|work> because the signatures don't match
[13:54] <radekp> and on .NET they match?
[13:54] <klausT|work> on Windows you have usually the WINAPI/STDCALL calling convention
[13:55] <klausT|work> the struct return value is handled different there
[13:55] <klausT|work> the callee pops the args from the stack and pushes the return value
[13:57] <klausT|work> o no additional arg for the return value
[13:59] <radekp> so the conclusion is that the pinvoking is badly declared and will work on windows only?
[14:01] <klausT|work> yes, if the c function returns an int the return value in C# has to be int too