This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.
Neels Hofmeyr nhofmeyr at sysmocom.deOn Sat, Nov 07, 2015 at 02:00:51PM +0100, Alexander Huemer wrote: > so I guess the right format specifier to use here is "%td", since the > expression is (something like) a ptrdiff_t. Thanks, it's actually the first time I come across ptrdiff_t. From the explanations I've found, this is The Correct (TM) type to use, indeed. In my /usr/lib/gcc/x86_64-linux-gnu it's defined as long int. I ask myself though -- for linkage size smaller than 2 GB, apparently the default everywhere, pointer differences will stay within the 32 bit address range, and using an int should suffice? To link surpassing 2 GB, one needs to explicitly pass -mcmodel=medium to gcc, and I doubt any osmo project will surpass 2 GB linkage any time soon ;) Instead of reading man snprintf all the time, I actually tend to use %d and cast the argument to (int) :P This will only work if the thing to print is entirely within the int range, of course. uint16_t x = 5; printf("%d", (int)x); An advantage here is that the type of x can be tweaked later without having to edit the formats everywhere (error prone). I can't really find them now, but I dimly remember seeing some osmo code here and there where printf() formats could use some more attention... Like, is it accurate to pass an enum type to %d without casting? And so on. Most of those instances still print the correct value because, I assume, actual storage of the values is often blown up to the CPU's native size... (handwavy) ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.osmocom.org/pipermail/openbsc/attachments/20151118/11adb97f/attachment.bin>