Ecb: alignas and alignof support

Zsb√°n Ambrus ambrus at
Sat Sep 5 01:10:36 CEST 2015

I've prepared a patch and test to add alignas and alignof support to
the ecb library.  This is "ecb-alignas0.patch", attached to this mail.

While making this patch, I found out a lot about strange behavior of
certain compilers, but probably not everything, so there may still be

I've made a test program "ecb_align_test.c" that can check some of the
behavior of the patch.  After patching libecb.h, please compile and
run the test program with whatever compiler you have available, and
see if it works.  I recommend that you try to compile it separately as
a C source and a C++ source, because the patch should work in both
cases, but the language and available features differ.  I also
recommend that you build in both a C11 and C99 mode, and both a C++11
(or later) and C++98 mode, if your compiler has such an option.  I
will test with msvc 2013 next week.  The program should compile, and
when ran, print "Alignas test ok." after some other debug information.
If you get a failure, please report on the mailing list, possibly with
a patch.

Some notes about the implementation.
1. I do not check for the version of gcc, because even on a new enough
version there seems to be no way to use alignas or _Alignas in C99 or
C++98 mode.
2. Msvc gives an error to a declaration like __declspec(align(1))
__declspec(align(64)) which is why I insist on no doubled
3. Clang gives a syntax error to a declaration like
__attribute__((unused)) alignas(64) char x; which is why the
documentation insists that ecb_alignas(v) much come before ecb_unused.
4. I don't allow putting the ecb_alignas(v) after a variable name,
because MSC gives a syntax error to a declaration like int x
5. I haven't tried more exotic compilers, or old versions of
compilers, at all.  It's likely that there will be failures on some
compilers other than gcc, clang, msc.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecb-alignas0.patch
Type: text/x-diff
Size: 3460 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecb_align_test.c
Type: text/x-csrc
Size: 1997 bytes
Desc: not available
URL: <>

More information about the libev mailing list