[systemd-devel] [PATCH] use static_assert instead of assert_cc

Thomas H.P. Andersen phomes at gmail.com
Sun Dec 30 13:02:11 PST 2012


On Sun, Dec 30, 2012 at 4:32 PM, Zbigniew Jędrzejewski-Szmek
<zbyszek at in.waw.pl> wrote:
> On Sat, Dec 29, 2012 at 11:14:15PM +0100, Thomas H.P. Andersen wrote:
>> On Sat, Dec 29, 2012 at 5:04 PM, Zbigniew Jędrzejewski-Szmek
>> <zbyszek at in.waw.pl> wrote:
>> > On Sat, Dec 29, 2012 at 02:10:27AM +0100, Thomas H.P. Andersen wrote:
>> >> Another item from the todo
>> > Hi,
>> >
>> > the patch looks great, but it raises compatibility problems. AFAICT,
>> > required gcc version to raised to 4.6. Debian/squeeze has 4.4.
>>
>> According to http://gcc.gnu.org/projects/cxx0x.html static_assert
>> should be supported from gcc 4.3
> Hm, testing (with 4.4) shows that neither static_assert nor _Static_assert
> are available. With 4.6 _Static_assert is available.
>
> Michael Biebl says that Debian/squeeze doesn't have to be supported.
> This probably means that it's enough to have gcc-4.6 supported.
> This means that we don't need to support compilers which don't
> support _Static_assert.
>
>> > clang has _Static_assert, not static_assert. I think that a compile
>> > time check is in order. Support for old gcc versions is less
>> > important, so it might be enough to document the requirement in
>> > README, and then maybe provide a fallback if people complain. OTOH
>> > clang compilation support is useful (and used), so it should be kept.
>>
>> It builds with clang here. That is with "clang version 3.1
>> (branches/release_31)" from F18.
> static_assert is provided by /usr/include/assert.h (from glibc).
> since http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=839e283ec
> (Jan 01 2012). This version hasn't been officially released yet,
> AFAICT.  The define is trivial, and could be easily provided in
> missing.h.

Something like this?

The added part is:
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -257,3 +257,7 @@ static inline int name_to_handle_at(int fd, const
char *name, struct file_handle
 #ifndef TFD_TIMER_CANCEL_ON_SET
 #define TFD_TIMER_CANCEL_ON_SET (1 << 1)
 #endif
+
+#ifndef static_assert
+#define static_assert _Static_assert
+#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-use-static_assert-instead-of-assert_cc.patch
Type: application/octet-stream
Size: 14921 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20121230/270d0471/attachment.obj>


More information about the systemd-devel mailing list