On 2012-08-10 10:12:05 +0200, David Brown wrote: > On 10/08/2012 09:15, Göran Steen wrote: > >I want to make sure that my code snippets, if they are compiled and > >run on a machine with 16-bit int, still works. This is what I wish to do too. > >I don't have access to such a machine, so I want to compile and run > >them with 16-bit int on my machine that defaults to 32-bit int. Note that if your code snippets use functions from the C library, this won't work. > >Especially the intermediate results' size are interesting. What > >happens if they are truncated to 16-bit? > > The answer here is simple - #include <stdint.h>, and use types like > int_fast16_t. Actually you need to use your *own* type, say my_int16_t, and typedef it to int_fast16_t for the normal use of your code when <stdint.h> is available, to int for the normal use of your code when <stdint.h> is not available, and to int16_t (not int_fast16_t) for the tests. Now if you want to also test code with calls to the C library, you'll need to find a target with 16-bit int's to test everything. -- Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)