Bug 4911 - Suggestion: C long struct, backed by int in IL, but replaced on Mono
Summary: Suggestion: C long struct, backed by int in IL, but replaced on Mono
Status: RESOLVED INVALID
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: master
Hardware: PC Windows
: Lowest enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-05-06 23:50 UTC by James Bellinger
Modified: 2012-06-19 17:11 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description James Bellinger 2012-05-06 23:50:29 UTC
It would be nice if Mono included a library (perhaps it could be part of Mono.Posix) that had a struct, implemented like so:

It would have no public members, but have comparison operators, addition, etc. like a normal number. It would have implicit cast operator to either IntPtr or long, and explicit to int and other number type.

Implement it backed by a 4-byte int, as far as the IL is concerned.

In other words, it would act like a number.
Now the special part is, MS.NET does not exist on any platforms where long is not 4 bytes.

So, this special struct could, on *Mono* platforms, be automatically replaced by a genuine integer that is the size of a C long, as far as marshaling is concerned and the whole works. This would let Mono resolve all long integer portability problems between Linux and Windows on the same code base. This is an extension Mono could do with no repercussions.

On top of that it'd get people including a Mono-controlled class library on portable programs even on Windows, which would spread the usage of Mono APIs.
Comment 1 Miguel de Icaza [MSFT] 2012-06-19 17:11:22 UTC
This seems like something that should be prototyped elsewhere.