Can a project with AnyCpu architecture take different libraries depending on the pointer size? Those. something like this:
internal class SdlFunctions { private const string DllNameX64 = "x64\\sdl2.dll"; private const string DllNameX86 = "x86\\sdl2.dll"; #region SDL_video.h /// <summary> /// Get the number of video drivers compiled into SDL. /// </summary> [DllImport(DllNameX86, CallingConvention = CallingConvention.Cdecl)] internal static extern int SDL_GetNumVideoDrivers(); [DllImport(Is64Bit ? DllNameX86 : DllNameX64, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] internal static extern IntPtr SDL_CreateWindow(); #endregion private static bool Is64Bit => IntPtr.Size != 4; } But this will not work, because in the attribute DllImport need to pass a constant.
Is there anything else other than using the (Load\Free)Library ?
SDL_CreateWindow_32andSDL_CreateWindow_64, and in the code already check the bit depth and call the desired one. There will be no errors, because the library is loaded when it is called 2) When initializing the class where these functions are stored, dynamically load the necessary library. Functions from it will already be picked up automatically - a more elegant way and your case fits it. - John