I am looking for a portable method of checking whether overflow has occurred when multiplying unsigned integers. The way I have always done it in the past is to turn my unsigned integers into uint64_t's, multiply, then create a uint64_t with a value of 2 to the 32nd power and if that is less than or equal to the product, I have overflowed. However, that assumes that unsigned ints are always 32 bits, which I cannot assume, so I want to ditch that bad habit. Plus that still leaves the problem of detecting overflow when multiplying two uint64_t values. I've been researching it online and a few people have suggested using compiler flags, which I am not crazy about because then I can't just post code online at a place like Daniweb and assume everyone will use the right flags.
Dusting the cobwebs off, I remember that internally, an overflow bit is set somewhere when the CPU executes a multiply operation and overflow occurs. That seems like the best way to do things since the CPU has already done it so there is nothing to code by me, correct? My questions are "Is this understanding correct?", "Can I access this bit using C++?", and "Is this indeed the best approach?"