3 ms·
Use the compiler intrinsics (__builtin_add_overflow, etc.): that's what they're there for. They are guaranteed to generate the most efficient code.
by pcwalton 8y ago
Use the compiler intrinsics (__builtin_add_overflow, etc.): that's what they're there for. They are guaranteed to generate the most efficient code.
- pjmlp 8y agoWith plenty of #ifdef #else #endif, as they aren't portable.
- nkurz 8y agoInstead of obfuscating with ifdef's, what's the downside of just using a non-standard but well-supported intrinsic that works for major compilers on common systems? For closed source, you are distributing a binary anyway, and have control of the compiler you choose. For open source, it may fail to compile, but the error message should make it clear what needs to be done (probably linking in a function written in assembly for the unsupported platform).