Fix generation of long-typed defines when on Linux#699
Draft
Exanite wants to merge 10 commits into
Draft
Conversation
This is my initial guess for what the output should look like.
Member
Author
|
There is also a similar case with Also from OpenCL: #if INTPTR_MAX == INT32_MAX
#define CL_ICD2_TAG_KHR ((intptr_t)0x434C3331)
#else
#define CL_ICD2_TAG_KHR ((intptr_t)0x4F50454E434C3331)
#endifThis generates as the following on both Windows and Linux: [NativeTypeName("#define CL_ICD2_TAG_KHR ((intptr_t)0x4F50454E434C3331)")]
public const nint CL_ICD2_TAG_KHR = unchecked((nint)(0x4F50454E434C3331));In this case, the only change needed to make this compile would be to replace |
… other observations
Will keep investigating the conditions a bit more since I'm not quite convinced this is optimal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is more an issue report than a PR since I want to discuss the issue first, but is opened as a PR because it involves some proposed test cases and I'm also interested in fixing it.
Please let me know if the proposed changes are reasonable.
For context, C
longis output as C#ninton Linux.This causes an issue where a 64-bit
ulongvalue is used as the initializer for aconstfield of typenint, leading to 2 errors:longtonint.nintuntil run time, this errors withConstant initializer must be compile-time constantafter fixing the first error. Edit: Looks like this is specified here: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/native-integers.mdCurrent test outputs (matching main branch)
The
CLongDefinesTestWindowstest case already passes and is there to ensure that no unintended changes occur to the Windows behavior.Expected test outputs
The expected test outputs are my proposal for roughly what the expected bindings output should look like.
Notably, we need to add a type cast and change the field to be a
static readonlyfield instead of aconstfield.