-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sizeof test to runtime, query the C++ compiler
We should strive to query the C++ compiler as much as possible instead of relying on hardcoded values, as it ensures that any change (new standard, new compiler, new platform) will catch the bug, which relying on hardcoded value will not.
- Loading branch information
Showing
4 changed files
with
36 additions
and
9 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,12 @@ | ||
/******************************************************************************* | ||
Utilities to be used in tests | ||
*******************************************************************************/ | ||
|
||
module stdcpp.test.base; | ||
|
||
version (unittest): | ||
|
||
/// Returns: the `sizeof` of `T` as seen by the C++ compiler | ||
extern(C++, "stdcpp", "test") size_t cppSizeOf (T) (); |
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