2010/2/16 Vladimir 'φ-coder/phcoder' Serbinenko <phco...@gmail.com>: > Michal Suchanek wrote: >>> With typeof macro this can be made type-neutral avoiding potential mistakes. >>> +static inline long >>> +grub_min (long x, long y) >>> +{ >>> + if (x > y) >>> + return y; >>> + else >>> + return x; >>> +} >>> + >>> >> >> I don't see how typeof would be used. As I understand the docs it can >> only set types relative to something what is already defined (and in >> some cases actually dereference/call it) and there is nothing defined >> at the point these functions are declared to copy the type from. >> > #include <stdio.h> > #define swap(a,b) {typeof (a) mytemp ## __LINE__; mytemp ## __LINE__ = > b; b = a; a = mytemp ## __LINE__; } >
Unlike inlines this pollutes the local namespace with unexpected identifiers.. Perhaps the temporary variable should be at least prefixed with an underscore or something. But if that is ok then perhaps the existing functions in include/grub/misc.h should be converted. There is grub_max, grub_abs and grub_div_roundup already. Thanks Michal _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel