Le 17/06/2014 19:16, Achim Gratz a écrit : > Thierry Banel writes: >> You are right, INT_MAX is the C++ constant to compare to. >> It is defined in limits.h >> >> I'm not sure I want to locate limits.h (where is it ? are there several >> versions ?), >> and parse it, all from within Emacs-lisp... > No, this isn't something you should even try. The only method that is > known to work is what autoconf does: compile a program and check the > output. Absolutely right. Or use "getconf INT_MAX" as suggested by Nick Dokos, but this does not works everywhere. >> And this will have to be done for all languages (Python, Perl, Java, >> and so on), not just C++. > Let's stick with C(++) and solve that problem first, that there is a lot > of boilerplate code in Babel language support that should be lifted off > elsewhere is a discussion for another time. I do agree.
By the way, other languages may not be as tricky. - Java specifies int to be exactly 32 bits, long to be 64 bits. http://en.wikibooks.org/wiki/Java_Programming/Primitive_Types - Same goes for D. http://dlang.org/type.html - In C++ there is a new specification with types like: |int_least32_t| // at least 32 bits |int32_t // exactly 32 bits| http://en.cppreference.com/w/cpp/types/integer >> Or we could assume that INT_MAX is always 2147483647. >> (Which of course is not true). > You've just made compilers customizable. For a start, make those > constants customizable per compiler as well? > Thomas S. Dye suggested just that. Should we throw this detail at the user ? She will have a hard time figuring out why we bother her with integer size. Regards Thierry