CppSharp icon indicating copy to clipboard operation
CppSharp copied to clipboard

[s]int8 in structures throw not implemented exception

Open ghost opened this issue 4 years ago • 4 comments
trafficstars

In this function a NotImplementedException is thrown when a structure contains a member of type int8_t. Noting that the rest of this library appears to support signed bytes; however, this one particular class in the C# frontend doesn't handle them in its' two static functions

ghost avatar Aug 07 '21 09:08 ghost

@ReeceSX Seems like an oversight, I think we need to add the following line, along with a test:

                case PrimitiveType.Char:
+               case PrimitiveType.SChar:
                    signed = true;
                    return (targetInfo.CharWidth, targetInfo.CharAlign);

Do you wanna try sending a PR fixing this?

Re-reading this code, I'm thinking we might also have another bug here. Right now we just assume that char will always be signed, but I think that may not be the case with -funsigned-char.

EDIT: On further thought, maybe that is already handled by the thought that Clang already returns.

For reference, here is the code where Clang figures out what signedness to use: https://github.com/llvm/llvm-project/blob/4389a413e2129d7d55ee779638b649aa852b6f8a/clang/lib/Driver/ToolChains/Clang.cpp#L1438

tritao avatar Aug 07 '21 11:08 tritao

I'm unable to work on this right; however, if it helps, the target toolchain was msvc. Perhaps there is some deviation between clangs internal ABI expectations based on the MSVCToolChain driver.

ghost avatar Aug 21 '21 15:08 ghost

I had the same Problem with MSVC. Adding case PrimitiveType.SChar: fixed it for me.

as14df avatar Sep 07 '21 17:09 as14df

We're running into the same issue with NuGet release 1.0.1.

rberleo avatar Mar 29 '22 13:03 rberleo