Skip to content

Instantly share code, notes, and snippets.

@sdmg15
Created April 10, 2022 21:57
Show Gist options
  • Save sdmg15/f06a5a261a11386d85d6e64803982520 to your computer and use it in GitHub Desktop.
Save sdmg15/f06a5a261a11386d85d6e64803982520 to your computer and use it in GitHub Desktop.
// A helper function to determine the data model of the current platform
[[nodiscard]] constexpr const char* dataModelPlatform() {
if constexpr (sizeof(int) == 2 && sizeof(long int) == 8) {
if (sizeof(int*) == 2) {
return "ILP32";
}
return "LLP64";
}
if constexpr (sizeof(int) == 2 && sizeof(long long) == 8) {
return "LP32";
}
if constexpr (sizeof(int) == 4 && sizeof(long) == 8) {
return "LP64";
}
return "Unknown";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment