[winpr,spec] fix windows compatibility

define NONAMELESSUNION to have the same struct definitions under windows
as we have under linux.
This commit is contained in:
akallabeth
2024-10-30 08:58:20 +01:00
committed by Armin Novak
parent 17295d114b
commit 7842891d0f
4 changed files with 28 additions and 8 deletions

View File

@@ -140,6 +140,9 @@ endif()
message(STATUS "Git Revision ${GIT_REVISION}")
# MSVC compatibility with system headers
add_definitions(-DNONAMELESSUNION)
# Make the detected version available as default version for all subprojects
set(FREERDP_DEFAULT_PROJECT_VERSION ${FREERDP_VERSION} CACHE STRING INTERNAL)

View File

@@ -61,6 +61,9 @@ if(NOT FREERDP_UNIFIED_BUILD)
else()
set(DEFAULT_DEBUG_OPTION "OFF" CACHE INTERNAL "debug default")
endif()
# MSVC compatibility with system headers
add_definitions(-DNONAMELESSUNION)
endif()
if(WIN32 AND NOT UWP)

View File

@@ -35,6 +35,7 @@ WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER
#else
#if defined(NONAMELESSUNION)
#define DUMMYUNIONNAME u
#define DUMMYUNIONNAME1 u1
#define DUMMYUNIONNAME2 u2
@@ -51,6 +52,24 @@ WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER
#define DUMMYSTRUCTNAME3 s3
#define DUMMYSTRUCTNAME4 s4
#define DUMMYSTRUCTNAME5 s5
#else
#define DUMMYUNIONNAME
#define DUMMYUNIONNAME1
#define DUMMYUNIONNAME2
#define DUMMYUNIONNAME3
#define DUMMYUNIONNAME4
#define DUMMYUNIONNAME5
#define DUMMYUNIONNAME6
#define DUMMYUNIONNAME7
#define DUMMYUNIONNAME8
#define DUMMYSTRUCTNAME
#define DUMMYSTRUCTNAME1
#define DUMMYSTRUCTNAME2
#define DUMMYSTRUCTNAME3
#define DUMMYSTRUCTNAME4
#define DUMMYSTRUCTNAME5
#endif
#if (defined(_M_AMD64) || defined(_M_ARM)) && !defined(_WIN32)
#define _UNALIGNED __unaligned

View File

@@ -11,15 +11,10 @@ int TestGetNativeSystemInfo(int argc, char* argv[])
GetNativeSystemInfo(&sysinfo);
#if defined(DUMMYUNIONNAME) && defined(DUMMYSTRUCTNAME)
#define DUMMYXPTR(x) x.DUMMYUNIONNAME.DUMMYSTRUCTNAME
#else
#define DUMMYXPTR(x) x
#endif
printf("SystemInfo:\n");
printf("\twProcessorArchitecture: %" PRIu16 "\n", DUMMYXPTR(sysinfo).wProcessorArchitecture);
printf("\twReserved: %" PRIu16 "\n", DUMMYXPTR(sysinfo).wReserved);
printf("\twProcessorArchitecture: %" PRIu16 "\n",
sysinfo.DUMMYUNIONNAME.DUMMYSTRUCTNAME.wProcessorArchitecture);
printf("\twReserved: %" PRIu16 "\n", sysinfo.DUMMYUNIONNAME.DUMMYSTRUCTNAME.wReserved);
printf("\tdwPageSize: 0x%08" PRIX32 "\n", sysinfo.dwPageSize);
printf("\tlpMinimumApplicationAddress: %p\n", sysinfo.lpMinimumApplicationAddress);
printf("\tlpMaximumApplicationAddress: %p\n", sysinfo.lpMaximumApplicationAddress);