Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving
bool
include hacks into a dedicated header file.
This was inspired (in the initial commit [1]) by a header from `msgpack` [2] (and also some help from StackOverflow [3] about `_MSC_VER` and Matthew Brett's pydagogue doc [4]). The "last" modification (in [5]) diverges from the original ([2]) by using `char` instead of `int` as the `bool` alias on Windows. This is so that we can remain true to the binary interface. [1]: 833643f [2]: https://github.com/msgpack/msgpack-c/blob/b02c6beb4dfc28b9651ac78e583d2273aef679a7/include/msgpack/sysdep.h#L180-L195 [3]: https://stackoverflow.com/a/5850405/1068170 [4]: http://matthew-brett.github.io/pydagogue/python_msvc.html [5]: 6fb9da2
- Loading branch information
Showing
4 changed files
with
50 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef BEZIER_BOOL_PATCH_H | ||
#define BEZIER_BOOL_PATCH_H | ||
|
||
#if defined (__cplusplus) | ||
extern "C" { | ||
#elif !defined (_MSC_VER) | ||
#include <stdbool.h> | ||
#endif | ||
|
||
#if !defined (__cplusplus) && defined (_MSC_VER) | ||
# if !defined (FALSE) | ||
# define FALSE (0) | ||
# endif | ||
# if !defined (TRUE) | ||
# define TRUE (!FALSE) | ||
# endif | ||
# if _MSC_VER >= 1800 | ||
# include <stdbool.h> | ||
# else | ||
// NOTE: We must use `char` because it is 1 byte, as `bool` is | ||
// in C99 and later (which is what `gfortran` uses). | ||
# define bool char | ||
# define true TRUE | ||
# define false FALSE | ||
# endif | ||
#endif | ||
|
||
#if defined (__cplusplus) | ||
} | ||
#endif | ||
|
||
#endif /* BEZIER_BOOL_PATCH_H */ |
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
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