forked from kokkos/kokkos-core-wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kokkos#195 from JBludau/windows_h_include
Short explanation to windows.h problem
- Loading branch information
Showing
2 changed files
with
8 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |