dawn-cmake/src/common/windows_with_undefs.h
Corentin Wallez 13110bff05 d3d12_platform: ensure windows.h macros don't cause compile errors
The windows.h macros were undefined only at the end of this platform
header previously but with the addition of d3d12sdklayers.h the
definition of ID3D12DebugQueue::GetMessage picked up the macro and
became GetMessageA or GetMessageW, but Dawn code referred to it as
GetMessage causing a compilation error.

Fix this by preemptively loading windows.h and undefing some of the
macros so that the D3D12 headers don't see them.

Bug:
Change-Id: I1985cc20a9bdec1d25619ac5088e918b2acf8ecb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22400
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-01 13:58:22 +00:00

36 lines
1.2 KiB
C

// Copyright 2018 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef COMMON_WINDOWS_WITH_UNDEFS_H_
#define COMMON_WINDOWS_WITH_UNDEFS_H_
#include "common/Platform.h"
#if !defined(DAWN_PLATFORM_WINDOWS)
# error "windows_with_undefs.h included on non-Windows"
#endif
// This header includes <windows.h> but removes all the extra defines that conflict with identifiers
// in internal code. It should never be included in something that is part of the public interface.
#include <windows.h>
// Macros defined for ANSI / Unicode support
#undef CreateWindow
#undef GetMessage
// Macros defined to produce compiler intrinsics
#undef MemoryBarrier
#endif // COMMON_WINDOWS_WITH_UNDEFS_H_