lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 32abc67 2/4: Transplant and refine built-in-t


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 32abc67 2/4: Transplant and refine built-in-type size assertions
Date: Wed, 6 Jun 2018 18:55:31 -0400 (EDT)

branch: master
commit 32abc672daa02de53bfee2d8726ade2337f6096d
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Transplant and refine built-in-type size assertions
    
    Moved these static assertions to a file that's always included in every
    binary, because lmi assumes them to be valid universally. To that end,
    included 'main_common.hpp' in 'cpp_main.cpp', so that unit-test binaries
    are also built with these assertions.
    
    Dropped the 'short int' assertion: that type is unimportant in this
    millennium. Improved the 'int' assertion: larger 'int' is okay.
---
 actuarial_table.cpp | 4 ----
 cpp_main.cpp        | 1 +
 main_common.hpp     | 3 +++
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/actuarial_table.cpp b/actuarial_table.cpp
index 81ba5e4..bdac70a 100644
--- a/actuarial_table.cpp
+++ b/actuarial_table.cpp
@@ -98,10 +98,6 @@ actuarial_table::actuarial_table(std::string const& 
filename, int table_number)
     static_assert(std::endian::native == std::endian::little);
 #endif // 201900L < __cplusplus
 
-    static_assert(8 == CHAR_BIT);
-    static_assert(4 == sizeof(int));
-    static_assert(2 == sizeof(short int));
-
     if(table_number_ <= 0)
         {
         alarum()
diff --git a/cpp_main.cpp b/cpp_main.cpp
index 7326cf8..9d89cd1 100644
--- a/cpp_main.cpp
+++ b/cpp_main.cpp
@@ -61,6 +61,7 @@
 #include "catch_exceptions.hpp"
 #include "getopt.hpp"
 #include "license.hpp"
+#include "main_common.hpp"
 
 #include <cstdlib>                      // free()
 #include <iostream>
diff --git a/main_common.hpp b/main_common.hpp
index b9b2e0b..e51fdd0 100644
--- a/main_common.hpp
+++ b/main_common.hpp
@@ -27,6 +27,9 @@
 // Included so that try_main() definitions can use EXIT_SUCCESS, EXIT_FAILURE.
 #include <cstdlib>
 
+static_assert(8 == CHAR_BIT);
+static_assert(4 <= sizeof(int));
+
 void initialize_application();
 int try_main(int argc, char* argv[]);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]