geany/geany — comment on commit efcce8808e92ba56684605790959cb014a11c9c8
File:  line 0
By b4n:

Le 07/11/2011 03:26, elextr a écrit :
> […]
>
> if autofools uses the AC_C_INLINE (Waf I dunno) then the following will work:

IIRC GLib defines `inline` to something sensible (e.g. nothing) if it's
not supported too, so we wouldn't need the AC stuff, just include
glib.h. Needs to be checked though.

> inline void setptr(gpointer p, gpointer r){ gpointer t=p; p = r; g_free(t); };

Hum, stop me if I'm wrong (I'm not inline guru), but AFAIK inlines just
work as plain functions, so `p` wouldn't change outside of `setptr()`.

(BTW septr should definitely at least expand to `do { … } while (0)`
rather than `{ … }`, gave me one or two headaches.

> If AC_C_TYPEOF is also used then NVL and NZV can be made safe, with
> fallback to current unsafe:
>
> #ifdef HAVE_TYPEOF
> #define NZV(a)\
> ({ typeof (a) _a = (a); \
> _a && _a[0]; })
> #else
> #define NZV(a) ((a) && (a)[0])
> #endif
>
> #ifdef HAVE_TYPEOF
> #define NVL(a,b) \
> ({ typeof (a) _a = (a); \
> typeof (b) _b = (b); \
> _a ? _a : _b; })
> #else
> #define NVL(X #endif

Having the fallback to an unsafe version defeats most of the advantages,
maybe even making the code worse since one could think it works just
because she has typeof (huh, GNUC actually, `typeof` + `({})`); where
for people without it it'd fail.