[v5] eal: define __SIZEOF_LONG__ when using MSVC
Checks
Commit Message
Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it.
Therefore the errors below are seen with MSVC:
../lib/mldev/mldev_utils_scalar.c(465): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar.c(478): error C2051:
case expression not constant
../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
'__SIZEOF_LONG__': undeclared identifier
../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
case expression not constant
The fix is to define __SIZEOF_LONG__ in a common header when
MSVC is used.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
lib/eal/include/rte_compat.h | 5 +++++
1 file changed, 5 insertions(+)
Comments
On Wed, Feb 5, 2025 at 5:12 PM Andre Muezerie
<andremue@linux.microsoft.com> wrote:
>
> Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it.
> Therefore the errors below are seen with MSVC:
>
> ../lib/mldev/mldev_utils_scalar.c(465): error C2065:
> '__SIZEOF_LONG__': undeclared identifier
> ../lib/mldev/mldev_utils_scalar.c(478): error C2051:
> case expression not constant
>
> ../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
> '__SIZEOF_LONG__': undeclared identifier
> ../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
> case expression not constant
>
> The fix is to define __SIZEOF_LONG__ in a common header when
> MSVC is used.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
> lib/eal/include/rte_compat.h | 5 +++++
> 1 file changed, 5 insertions(+)
rte_compat only deals with symbol versioning.
I think a better location would be windows/rte_os.h.
On Fri, Feb 07, 2025 at 11:56:13AM +0100, David Marchand wrote:
> On Wed, Feb 5, 2025 at 5:12 PM Andre Muezerie
> <andremue@linux.microsoft.com> wrote:
> >
> > Macro __SIZEOF_LONG__ is not standardized and MSVC does not define it.
> > Therefore the errors below are seen with MSVC:
> >
> > ../lib/mldev/mldev_utils_scalar.c(465): error C2065:
> > '__SIZEOF_LONG__': undeclared identifier
> > ../lib/mldev/mldev_utils_scalar.c(478): error C2051:
> > case expression not constant
> >
> > ../lib/mldev/mldev_utils_scalar_bfloat16.c(33): error C2065:
> > '__SIZEOF_LONG__': undeclared identifier
> > ../lib/mldev/mldev_utils_scalar_bfloat16.c(49): error C2051:
> > case expression not constant
> >
> > The fix is to define __SIZEOF_LONG__ in a common header when
> > MSVC is used.
> >
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > ---
> > lib/eal/include/rte_compat.h | 5 +++++
> > 1 file changed, 5 insertions(+)
>
> rte_compat only deals with symbol versioning.
> I think a better location would be windows/rte_os.h.
>
>
>
> --
> David Marchand
Thanks for the suggestion. I updated the patch accordingly.
@@ -66,4 +66,9 @@ __attribute__((section(".text.internal")))
#endif
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __SIZEOF_LONG__ (sizeof(long))
+#define __SIZEOF_LONG_LONG__ (sizeof(long long))
+#endif
+
#endif /* _RTE_COMPAT_H_ */