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

On Tue, Nov 8, 2011 at 2:19 AM, Colomban Wendling

wrote:
> 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.

Just so long as something does, it doesn't matter what :)

>
>> 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()`.

Ah yeah, oops, thinking too much of C++ reference parameters.

>
> (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.

Well, it would fail depending on the values, which is the situation
now. So without a guarantee of typeof I guess we can only continue to
be VEWWWY careful using these.

Cheers
Lex
>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/geany/geany/commit/efcce8808e92ba56684605790959cb014a11c9c8#commitcomment-700093
>