[v6] 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/windows/include/rte_os.h | 5 +++++
1 file changed, 5 insertions(+)
Comments
On Fri, Feb 07, 2025 at 07:04:28AM -0800, Andre Muezerie 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/windows/include/rte_os.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 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/windows/include/rte_os.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/lib/eal/windows/include/rte_os.h b/lib/eal/windows/include/rte_os.h
> index d09adeb3b4..c787027866 100644
> --- a/lib/eal/windows/include/rte_os.h
> +++ b/lib/eal/windows/include/rte_os.h
> @@ -56,4 +56,9 @@ struct { \
> */
> typedef long long ssize_t;
>
> +#ifdef RTE_TOOLCHAIN_MSVC
> +#define __SIZEOF_LONG__ (sizeof(long))
> +#define __SIZEOF_LONG_LONG__ (sizeof(long long))
> +#endif
> +
> #endif /* _RTE_OS_H_ */
> --
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> 2.47.2.vfs.0.1
On Fri, Feb 7, 2025 at 4:04 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>
Applied, thanks.
@@ -56,4 +56,9 @@ struct { \
*/
typedef long long ssize_t;
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __SIZEOF_LONG__ (sizeof(long))
+#define __SIZEOF_LONG_LONG__ (sizeof(long long))
+#endif
+
#endif /* _RTE_OS_H_ */