printf(INT_MAX);
limits.h is included, for some reason it’s not working in this particular project. In my testbed, it just works. I have no idea how to approach this problem other than removing every single file in the entire project until it starts working. This would be an inhuman amount of work. How can I find this bug faster? What are common causes of this?
I assume you’ve searched your own code and build system for instances where
INT_MAXmight get undefined.If possible, find a way to compile just the one source file (
.c), so that your iteration speed goes up. It is enough if yourMakefile(or whatever you use) already compiles only the changed file, instead of everything.Then, in the problematic file, add this before the first
#include, and after every#include:Then rebuild that module and see where the error happens.
If that fails, add the code snippet above here and there in the code to see where it gets undefined.
If it turns out that your
<limits.h>isn’t defining it, there are at least two possibilities:limits.hthan the standard oneHappy hacking.
PS. If you need to go through the process of removing files to find the problem, note that you can use binary search to speed things up: first remove one half of the files, and if the problem persists, you know it’s in the remaining files, and if not, in the files you removed, or, rarely, in the interaction between the two sets of files. Then iterate using the appropriate set of files, until you narrow it down to something sufficiently small.