Re: BUG #17967: [msvc-x86] Failed to build with error LNK2019: unresolved external symbol __BitScanReverse64 referen

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: moyoumiu@outlook.com, pgsql-bugs@lists.postgresql.org
Date: 2023-06-07T13:00:22Z
Lists: pgsql-bugs

Attachments

On Wed, 7 Jun 2023 at 23:26, PG Bug reporting form
<noreply@postgresql.org> wrote:
> The file `src/bin/pg_verifybackup/pg_verifybackup.c` fails to compile using
> msvc under x86, there is no `_BitScanForward64` and `_BitScanReverse64`
> under **x86** for head `src/include/port/pg_bitutils.h`.

I guess not many people are building on 32-bit MSVC these days.

I've not tested it, but I imagine the attached patch should fix it.

The ARM-64 part I included in the patch is just future-proofing.
Maybe I shouldn't bother with it.

David

Commits

  1. Don't use _BitScanForward64/_BitScanReverse64 on 32-bit MSVC builds

  2. Remove newly added asserts from pg_bitutils.h

  3. Add MSVC support for pg_leftmost_one_pos32() and friends