In the previous discussion, I tried to enable HAVE_OVERFLOW_CHECKS on msvc but failed. https://cm-mail.stanford.edu/pipermail/cmdist/2024-December/009360.html <https://cm-mail.stanford.edu/pipermail/cmdist/2024-December/009360.html > Since I have found that enable HAVE_OVERFLOW_CHECKS is expensive on MSVC, I decide to disable HAVE_OVERFLOW_CHECKS on Linux and macOS. And currently, it is not possible to disable HAVE_OVERFLOW_CHECKS: #ifndef HAVE_OVERFLOW_CHECKS #if ((defined(__clang__) && (!POINTER_32) && ((__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ >= 4))) || (defined(__GNUC__) && (__GNUC__ >= 5))) #define HAVE_OVERFLOW_CHECKS 1 #else #define HAVE_OVERFLOW_CHECKS 0 #pragma message("no arithmetic overflow checks in this version of s7") /* these are untested */ static bool add_overflow(s7_int A, s7_int B, s7_int *C) {*C = A + B; return(false);} /* #define add_overflow(A, B, C) 0 */ static bool subtract_overflow(s7_int A, s7_int B, s7_int *C) {*C = A - B; return(false);} /* #define subtract_overflow(A, B, C) 0 */ static bool multiply_overflow(s7_int A, s7_int B, s7_int *C) {*C = A * B; return(false);} /* #define multiply_overflow(A, B, C) 0 */ #endif #endif Because it is actually controlled by the compiler and there is no way to disable the compiler flag without patching s7.c. Here is my suggestion: #ifndef HAVE_OVERFLOW_CHECKS // define HAVE_OVERFLOW_CHECKS to 0 or 1 according to compilers #endif #if HAVE_OVERFLOW_CHECKS == 0 static bool add_overflow(s7_int A, s7_int B, s7_int *C) {*C = A + B; return(false);} /* #define add_overflow(A, B, C) 0 */ static bool subtract_overflow(s7_int A, s7_int B, s7_int *C) {*C = A - B; return(false);} /* #define subtract_overflow(A, B, C) 0 */ static bool multiply_overflow(s7_int A, s7_int B, s7_int *C) {*C = A * B; return(false);} /* #define multiply_overflow(A, B, C) 0 */ #endif
_______________________________________________ Cmdist mailing list [email protected] https://cm-mail.stanford.edu/mailman/listinfo/cmdist
