Skip to content

Commit

Permalink
Use compile option -fno-strict-aliasing to prevent breaking optimizat…
Browse files Browse the repository at this point in the history
…ions due to using reinterpret_cast
  • Loading branch information
asuessenbach committed Oct 30, 2024
1 parent 17a245e commit d6553d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function( vulkan_hpp__setup_platform )
else()
message( FATAL_ERROR, "Vulkan-Hpp: unhandled platform!" )
endif()
target_compile_options( ${TARGET_NAME} PRIVATE -fno-strict-aliasing )
endfunction()

function( vulkan_hpp__setup_vulkan_include )
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,10 @@ Currently, there are just a couple of such defines:
- `VULKAN_HPP_NO_TO_STRING`, which removes the various `vk::to_string` functions on enums and bitmasks.
- `VULKAN_HPP_USE_REFLECT`, this one needs to be defined to use the reflection function on structures. It's very slow to compile, though!

### Strict aliasing issue

As Vulkan-Hpp often needs to switch between C++ vk-types and corresponding bit-identical C-types, using `reinterpret_cast`, it is highly recommended to use the compile option `-fno-strict-aliasing` to prevent potentially breaking compile optimizations.

## Configuration Options

There are a couple of defines you can use to control the feature set and behaviour of `vulkan.hpp`:
Expand Down

0 comments on commit d6553d6

Please sign in to comment.