KhronosGroup / Vulkan-Hpp

Open-Source Vulkan C++ API
Apache License 2.0
3.08k stars 304 forks source link

IWYU pragmas for vulkan_{enums,funcs,structs}.hpp #1936

Closed rwols closed 1 month ago

rwols commented 1 month ago

As my code completer I am using clangd. Clangd automatically includes the relevant header when completing a function/struct/class. When code-completing a Vulkan-Hpp enum, it will include the header <vulkan/vulkan_enum.hpp>. Similarly for structs.

The headers vulkan_enums.hpp, vulkan_funcs.hpp and vulkan_structs.hpp are not meant to be included standalone from what I understand. They are meant to be included as part of including vulkan.hpp. When these headers are included standalone, a compilation error is the result.

Clangd respects the include-what-you-use pragmas: https://clangd.llvm.org/guides/include-cleaner#iwyu-pragmas

I believe what is needed to make clangd (and also the include-what-you-use tool) insert the correct header completion is to add a line like this to the three files:

// IWYU pragma: private; include "vulkan.hpp"

See also: https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-private

asuessenbach commented 1 month ago

Thanks for that hint, we'll add that pragma.