Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict #include dependency ordering #491

Open
rickyjames35 opened this issue Jul 31, 2024 · 1 comment
Open

Strict #include dependency ordering #491

rickyjames35 opened this issue Jul 31, 2024 · 1 comment
Labels
synced to gitlab Synchronized to OpenXR internal GitLab

Comments

@rickyjames35
Copy link
Contributor

There seems to be a required order of #includes when using openxr_platform.h.
For example, this compiles:

#define XR_USE_PLATFORM_ANDROID
#define XR_USE_GRAPHICS_API_VULKAN
#include <vulkan/vulkan.h>
#include <openxr/openxr_platform.h>

This does not:

#define XR_USE_PLATFORM_ANDROID
#define XR_USE_GRAPHICS_API_VULKAN
#include <openxr/openxr_platform.h>
#include <vulkan/vulkan.h>

You will see many errors about unknown Vulkan types like so....

error: unknown type name 'VkFormat'

The reason for this is openxr_platform.h has a dependency on vulkan.h but does not #include it. It's generally considered best practice to #include or forward declare dependencies directly in the header that's using them so the burden isn't on the user to infer the proper order of includes.
There is some good info in here for anyone new to this concept https://stackoverflow.com/questions/2762568/c-c-include-header-file-order

I would like to understand Khronos's philosophy on this. Also I may just be incorrectly adding OpenXR as a dependency to my project. However looking though https://github.com/KhronosGroup/OpenXR-Tutorials and the hello_xr test it seems they also have a strict ordering of the includes.

@rpavlik-bot
Copy link
Collaborator

An issue (number 2336) has been filed to correspond to this issue in the internal Khronos GitLab (Khronos members only: KHR:openxr/openxr#2336 ), to facilitate working group processes.

This GitHub issue will continue to be the main site of discussion.

@rpavlik-bot rpavlik-bot added the synced to gitlab Synchronized to OpenXR internal GitLab label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
synced to gitlab Synchronized to OpenXR internal GitLab
Projects
None yet
Development

No branches or pull requests

2 participants