A testdir of mbscasestr mcel-prefer when build with MSVC, produces link errors:
libgnu.a(mbscasestr.obj) : error LNK2019: unresolved external symbol __builtin_expect referenced in function mcel_tocmp libgnu.a(mbslen.obj) : error LNK2001: unresolved external symbol __builtin_expect test-mbscasestr1.exe : fatal error LNK1120: 1 unresolved externals make[4]: *** [Makefile:5079: test-mbscasestr1.exe] Error 2 The reason is that mcel.h uses __builtin_expect, but __builtin_expect is not defined. This patch fixes it. 2024-08-27 Bruno Haible <br...@clisp.org> mcel: Fix compilation error with MSVC. * modules/builtin-expect (Description): Improve. * m4/builtin-expect.m4: Improve comment. * modules/mcel (Depends-on): Add builtin-expect. diff --git a/m4/builtin-expect.m4 b/m4/builtin-expect.m4 index c7af926b34..33f255e9f5 100644 --- a/m4/builtin-expect.m4 +++ b/m4/builtin-expect.m4 @@ -1,11 +1,11 @@ # builtin-expect.m4 -# serial 1 +# serial 2 dnl Copyright 2016-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -dnl Check for __builtin_expect. +dnl Provide a GCC-compatible __builtin_expect macro in <config.h>. dnl Written by Paul Eggert. diff --git a/modules/builtin-expect b/modules/builtin-expect index c11d5d96c9..489a16894d 100644 --- a/modules/builtin-expect +++ b/modules/builtin-expect @@ -1,5 +1,5 @@ Description: -Check for __builtin_expect. +Provide a GCC-compatible __builtin_expect macro. Files: m4/builtin-expect.m4 diff --git a/modules/mcel b/modules/mcel index 59ca633641..4bdde8f95a 100644 --- a/modules/mcel +++ b/modules/mcel @@ -7,6 +7,7 @@ lib/mcel.h Depends-on: assert-h +builtin-expect extern-inline limits-h mbrtoc32