-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Architecture-dependent sizes in portable code #132
Comments
Basically what I propose is instead of |
Ok, after some thought, I've decided we'll try to support the following architecture sets in Cesium:
Notes:
|
Seems like We could either compile it using |
There's a problem: if we compile to
AnyCPU
, then we cannot generally determinesizeof(void*)
, which has to be a constant expression, according to the standard. Same about, say,size_t
orptrdiff_t
, and actually any architecture-dependent types, mostly derived from pointers.There are two possible strategies of dealing with that.
We can forbid using
sizeof
with a pointer and any pointer-sized types in portable code. Our users will have to specify the architecture when compiling a binary that uses these features.It is possible that this will effectively prevent compiling to
AnyCPU
of the most of C code.Also, using of such C libraries from external code would be problematic sometimes (the library author will have to distribute versions built for each architecture, which kinda loses the point of Cesium).
We can introduce a special architecture-independent compilation mode which will use 8 bytes for any pointer or
size_t
, and generally will prefer bigger object sizes, but will still allow building toAnyCPU
.This may be problematic for cases when a C library exposes some .NET interface which operates on pointer types of
IntPtr
: it's unclear how to properly compile that (or if it is even possible).For now, I am considering going both ways: add a flag to enable (or disable) architecture-independent compilation, and allow the user to specify the architecture that will be used to calculate
sizeof
and whatnot.Depends on:
The text was updated successfully, but these errors were encountered: