Created
January 25, 2022 11:51
-
-
Save keijiro/1cc523ef17f9904d718edc145de407e6 to your computer and use it in GitHub Desktop.
This file contains 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
#if HOGEHOGE | |
struct FullName | |
{ | |
[MarshalAs(UnmanagedType.LPStr)] public string first; | |
[MarshalAs(UnmanagedType.LPStr)] public string last; | |
} | |
[DllImport(_dll)] | |
static extern uint get_full_length(in FullName name); | |
void RunFullNameTest() | |
=> Debug.Log(get_full_length( | |
new FullName { first = "Keijiro", last = "Takahashi" })); | |
#else | |
struct FullName | |
{ | |
public IntPtr first; | |
public IntPtr last; | |
} | |
[DllImport(_dll)] | |
static extern uint get_full_length(in FullName name); | |
void RunFullNameTest() | |
{ | |
var p1 = Marshal.StringToHGlobalAnsi("Keijiro"); | |
var p2 = Marshal.StringToHGlobalAnsi("Takahashi"); | |
Debug.Log(get_full_length(new FullName { first = p1, last = p2 })); | |
Marshal.FreeHGlobal(p1); | |
Marshal.FreeHGlobal(p2); | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment