Skip to content

Commit

Permalink
Merge pull request kokkos#195 from JBludau/windows_h_include
Browse files Browse the repository at this point in the history
Short explanation to windows.h problem
  • Loading branch information
PhilMiller authored Oct 21, 2022
2 parents 260cd34 + 5247e94 commit 1022476
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/usecases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Use Cases and Examples
./usecases/Tasking
./usecases/Kokkos-Fortran-Interoperability
./usecases/SoA-and-AoSoA-with-Cabana
./usecases/WindowsHeader
7 changes: 7 additions & 0 deletions docs/source/usecases/WindowsHeader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Kokkos and `Windows.h`

When using Kokkos on Windows a program or library might include `windows.h`. This is problematic as this header defines two macros with the names `min` and `max` unless `NOMINMAX` is defined previously.
The preprocessor replaces strings in the source code with the macros yielding an uninterpretable result and thus compilation fails.
Therefore, the header `Kokkos_Core.hpp` is protected against these macros, meaning they are undefined at the beginning and redefined at the end of the header file.
Even though definitions inside `Kokkos_Core.hpp` are protected against the macros, code outside is not.
Thus, it is on the user to deal with the macros being defined, either by defining `-DNOMINMAX` or `/DNOMINMAX` in the compile line (preferred) or by putting `()` around names that contain `min` or `max`.

0 comments on commit 1022476

Please sign in to comment.