[1/2] build: build eal library with MSVC

Message ID 1709061720-4843-2-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series build eal & ring libraries with MSVC |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff Feb. 27, 2024, 7:21 p.m. UTC
  * MSVC now has limited handling of GCC __extension__ keyword when
  compiling C so only expand __extension__ empty on MSVC when
  building with C++.

* When building with MSVC enable the statement expressions compiler
  extension.

* When building with MSVC enable building of eal library.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 config/meson.build           | 7 ++++++-
 lib/eal/include/rte_common.h | 2 ++
 lib/meson.build              | 1 +
 3 files changed, 9 insertions(+), 1 deletion(-)
  

Patch

diff --git a/config/meson.build b/config/meson.build
index f8f2149..68186e1 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -39,13 +39,18 @@  if is_ms_compiler
     # temporarily disable msvc specific warnings
     # - 4244 compiler detected conversion of integer to smaller type
     # - 4267 compiler detected conversion of size_t to smaller type
-    add_project_arguments('/wd4244', '/wd4267', language: 'c')
+    # - 4146 unary minus applied to unsigned type
+    add_project_arguments('/wd4244', '/wd4267', '/wd4146', language: 'c')
 
     # enable non-locking atomic operations
     add_project_arguments('/experimental:c11atomics', language: 'c')
 
     # enable typeof operator
     add_project_arguments('/d1experimental:typeof', language: 'c')
+
+    # enable statement expressions extension
+    add_project_arguments('/experimental:statementExpressions', language: 'c')
+
 endif
 
 # set the major version, which might be used by drivers and libraries
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 1cc1222..99128d8 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -38,8 +38,10 @@ 
 #endif
 
 #ifdef RTE_TOOLCHAIN_MSVC
+#ifdef __cplusplus
 #define __extension__
 #endif
+#endif
 
 /*
  * RTE_TOOLCHAIN_GCC is defined if the target is built with GCC,
diff --git a/lib/meson.build b/lib/meson.build
index 4fb01f0..d77bfbc 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -73,6 +73,7 @@  if is_ms_compiler
             'log',
             'kvargs',
             'telemetry',
+            'eal',
     ]
 endif