Is it possible to detect an integer overflow with the Python ctypes module?
The docs suggest that none of the primitives support overflow checking, but I’d like to write my own so I can use native c types for my CPU emulator.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ctypes isn’t for doing operations on integers, it’s for calling functions in shareable libraries. Any relevant integer arithmetic would still have to be done in Python.
Unless the sharable library is itself providing integer-arithmetic functions, in which case it would have to do the overflow detection.