C++ provides std::end to getting the end of an array, and we know the size of the cbl_declarative_t::files array without using COUNT_OF.
libgcobol/ChangeLog: * common-defs.h (COUNT_OF): Remove. * exceptl.h (cbl_declarative_t): Use constant in assertion. * valconv.cc (__gg__exception_table_end): Use std::end instead of COUNT_OF. --- libgcobol/common-defs.h | 2 -- libgcobol/exceptl.h | 2 +- libgcobol/valconv.cc | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libgcobol/common-defs.h b/libgcobol/common-defs.h index d052f58b6df..ea6f91ba500 100644 --- a/libgcobol/common-defs.h +++ b/libgcobol/common-defs.h @@ -33,8 +33,6 @@ #include <stdint.h> #include <list> -#define COUNT_OF(X) (sizeof(X) / sizeof(X[0])) - // This constant establishes the maximum number of digits in a fixed point // number. We are using 37 digits as a maximum because a full-size 37-digit // number (10**37) takes 123 bits, and a full-size 38-digit number (10**38) diff --git a/libgcobol/exceptl.h b/libgcobol/exceptl.h index dedf5520e43..4c437f42f8a 100644 --- a/libgcobol/exceptl.h +++ b/libgcobol/exceptl.h @@ -152,7 +152,7 @@ struct cbl_declarative_t { , nfile(files.size()) , mode(mode) { - assert( files.size() <= COUNT_OF(this->files) ); + assert( files.size() <= files_max ); if( nfile > 0 ) { std::copy( files.begin(), files.end(), this->files ); } diff --git a/libgcobol/valconv.cc b/libgcobol/valconv.cc index 0b80d72cc3a..6ddc3c00c00 100644 --- a/libgcobol/valconv.cc +++ b/libgcobol/valconv.cc @@ -1701,5 +1701,5 @@ ec_descr_t __gg__exception_table[] = { "EC-VALIDATE-VARYING", "VARYING clause expression noninteger" }, } ; -ec_descr_t *__gg__exception_table_end = __gg__exception_table + COUNT_OF(__gg__exception_table); +ec_descr_t *__gg__exception_table_end = std::end(__gg__exception_table); -- 2.48.1