MSVC uses pragmas to indicate weak linking, so the old __rte_weak attribute needs to made into a macro so that the same syntax can be used for MSVC and other compilers like gcc.
This patch adds macro RTE_WEAK and deprecates __rte_weak. Signed-off-by: Andre Muezerie <andre...@linux.microsoft.com> --- lib/eal/include/rte_common.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 4d299f2b36..904b3ba5ec 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -137,10 +137,22 @@ typedef uint16_t unaligned_uint16_t; #define RTE_DEPRECATED(x) #endif +/** + * @deprecated + * @see RTE_WEAK + */ +#define __rte_weak (RTE_DEPRECATED(__rte_weak) __attribute__((__weak__))) + /** * Mark a function or variable to a weak reference. */ -#define __rte_weak __attribute__((__weak__)) +#ifdef RTE_TOOLCHAIN_MSVC +#define RTE_WEAK(FUNC_NAME) \ + (__pragma(comment(linker, "/alternatename:" #FUNC_NAME "=rte_weak_" \ + #FUNC_NAME)) rte_weak_ ## FUNC_NAME) +#else +#define RTE_WEAK(FUNC_NAME) (__attribute__((__weak__)) FUNC_NAME) +#endif /** * Mark a function to be pure. -- 2.47.0.vfs.0.3