KhronosGroup / MoltenVK

MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS.
Apache License 2.0
4.74k stars 413 forks source link

From Vulkan SDK 1.3.250.1, MoltenVK cannot be used in C files due to [[deprecated]] #2084

Open DuncanHopkinsFoundry opened 9 months ago

DuncanHopkinsFoundry commented 9 months ago

I am trying to include "MoltenVK/vk_mvk_moltenvk.h" into a C file (not a C++).

I am using Xcode 14.2 in the MESA code base, specifically "zink_screen.c".

Compilation fails due to the use of "[[deprecated]]" in "mvk_deprecated_api.h". Accord to cppreference.com this keyword is a 'C++14' keyword and not a 'C' keyword until 'C23'. As meson builds "*.c" as C11 and not C++ the compiler is failing. The C++ language is already set to C++17 and upping the C language as far as C23 is too far.

I personally have found a work around, to use the "VK_NO_PROTOTYPES" define to hide that part of the header.

billhollings commented 9 months ago

The vk_mvk_moltenvk.h file is deprecated legacy, and includes the following text:

/**
 * This header is provided for legacy compatibility only. This header contains obsolete and
 * deprecated MoltenVK functions, that were originally part of the obsolete and deprecated
 * non-standard VK_MVK_moltenvk extension, and use of this header is not recommended.
 *
 * Instead, in your application, use the following header file:
 *
 *     #include <MoltenVK/mvk_vulkan.h>
 *
 * And if you require the MoltenVK Configuration API, also include the following header file:
 *
 *     #include <MoltenVK/mvk_config.h>
 *
 * If you require access to Metal objects underlying equivalent Vulkan objects,
 * use the standard Vulkan VK_EXT_metal_objects extension.
 */
archbirdplus commented 8 months ago

I ran into this problem as well when using command-line clang 15.0, but switching to clang 17.0 resolved it. It looks like [[deprecated]] is supported just fine in newer versions of clang.