How do we feel about using pragmas and __attribute__ in C code?
http://bugs.python.org/issue12837 deals with the single compiler warning left on OS X: a tautalogical compare in socketmodule.c that is valid under POSIX. I have a solution that uses pragmas to turn off tautological compare warnings for the single 'if' statement that triggers it. But there are very few places in Python's code base which use pragmas and I have never seen a discussion if we are okay with their overall use. So is there any reason to not use pragmas sparsely in the code? Tying into this and using compiler-specific things in C code, what about __attribute__? http://bugs.python.org/issue19298 proposes an idea that Daniel Stutzbach originally came up with where we could use __atribute__ (behind a nicer macro) to help detect refleaks on PyObject* stack variables. Would __attribute__ usage be okay in that situation?
Brett Cannon <brett@yvrsfo.ca> wrote:
So is there any reason to not use pragmas sparsely in the code?
I'm +1 on using pragmas for suppressing selected warnings.
Tying into this and using compiler-specific things in C code, what about __attribute__? http://bugs.python.org/issue19298 proposes an idea that Daniel Stutzbach originally came up with where we could use __atribute__ (behind a nicer macro) to help detect refleaks on PyObject* stack variables. Would __attribute__ usage be okay in that situation?
I would have to see an example function, mostly to get an idea of how readable the code is. Stefan Krah
Am 13.12.2013 18:04, schrieb Brett Cannon:
http://bugs.python.org/issue12837 deals with the single compiler warning left on OS X: a tautalogical compare in socketmodule.c that is valid under POSIX. I have a solution that uses pragmas to turn off tautological compare warnings for the single 'if' statement that triggers it. But there are very few places in Python's code base which use pragmas and I have never seen a discussion if we are okay with their overall use.
+1 We should aim for zero compiler warnings. You may have to wrap the pragma in a #ifdef __clang__ block to silence warnings: http://buildbot.python.org/all/builders/AMD64%20Snow%20Leop%203.x/builds/830...
Tying into this and using compiler-specific things in C code, what about __attribute__? http://bugs.python.org/issue19298 proposes an idea that Daniel Stutzbach originally came up with where we could use __atribute__ (behind a nicer macro) to help detect refleaks on PyObject* stack variables. Would __attribute__ usage be okay in that situation?
+1, too. Christian
participants (3)
-
Brett Cannon -
Christian Heimes -
Stefan Krah