bazel: Bazel 7.0 - can't compile with `/DUNICODE` `/D_UNICODE`

Description of the bug:

We have defaults set to build using the Unicode version of the Microsoft APIs, using /DUNICODE /D_UNICODE to use the unicode version of the APIs by default. This has broken building external/bazel_tools/src/main/cpp/util/path_windows.cc Which should be using the APIs post fixed with “A” where the char type is always narrow.

external/bazel_tools/src/main/cpp/util/path_windows.cc(99): error C2664: 'DWORD ExpandEnvironmentStringsW(LPCWSTR,LPWSTR,DWORD)': cannot convert argument 1 from 'const _Elem *' to 'LPCWSTR'
        with
        [
            _Elem=char
        ]
external/bazel_tools/src/main/cpp/util/path_windows.cc(99): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\processenv.h(198): note: see declaration of 'ExpandEnvironmentStringsW'
external/bazel_tools/src/main/cpp/util/path_windows.cc(108): error C2664: 'DWORD ExpandEnvironmentStringsW(LPCWSTR,LPWSTR,DWORD)': cannot convert argument 1 from 'const _Elem *' to 'LPCWSTR'
        with
        [
            _Elem=char
        ]
external/bazel_tools/src/main/cpp/util/path_windows.cc(108): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\processenv.h(198): note: see declaration of 'ExpandEnvironmentStringsW'

Which category does this issue belong to?

C++/Objective-C Rules

What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Create an empty python binary and build that target

py_binary(
    name = "foo",
    srcs = [":foo.py"],
    python_version = "PY3",
    visibility = ["//visibility:public"],
)

With an empty windows project run this command. bazel build --copt=/D_UNICODE --copt=/DUNICODE //:foo

Which operating system are you running Bazel on?

windows

What is the output of bazel info release?

release 7.0.0rc1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

Yes, moving to bazel 7.0.0rc1

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

external/bazel_tools/src/main/cpp/util/path_windows.cc(99): error C2664: 'DWORD ExpandEnvironmentStringsW(LPCWSTR,LPWSTR,DWORD)': cannot convert argument 1 from 'const _Elem *' to 'LPCWSTR'
        with
        [
            _Elem=char
        ]
external/bazel_tools/src/main/cpp/util/path_windows.cc(99): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\processenv.h(198): note: see declaration of 'ExpandEnvironmentStringsW'
external/bazel_tools/src/main/cpp/util/path_windows.cc(108): error C2664: 'DWORD ExpandEnvironmentStringsW(LPCWSTR,LPWSTR,DWORD)': cannot convert argument 1 from 'const _Elem *' to 'LPCWSTR'
        with
        [
            _Elem=char
        ]
external/bazel_tools/src/main/cpp/util/path_windows.cc(108): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\processenv.h(198): note: see declaration of 'ExpandEnvironmentStringsW'

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 16 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@bazel-io fork 7.0.0