Niels Möller nisse@lysator.liu.se writes:
João Gomes writes:
In file included from nettle-meta.h:37:0, from non-nettle.h:38, from non-nettle.c:43: nettle-types.h:70:3: error: expected specifier-qualifier-list before ‘_Alignas’ In file included from ocb.h:38:0, from non-nettle.h:39, from non-nettle.c:43: aes.h:71:3: error: expected specifier-qualifier-list before ‘_Alignas’ aes.h:92:3: error: expected specifier-qualifier-list before ‘_Alignas’ aes.h:113:3: error: expected specifier-qualifier-list before ‘_Alignas’ make[1]: *** [Makefile:322: non-nettle.o] Error 1
Related to this note in NEWS:
In addition, support for alignof and alignas is required; these are part of C11, but intention is that this is the only required C11 feature.
For your information, I can compile it without any errors on x86-x64, but not on ARM anymore.
Which compiler and compiler options did you have this problem with? It's somewhat odd that you appear to have stdalign.h, and a macro alignas expanding to _Alignas, but the latter not working as expected.
Apparently, this was with gcc-4.5.3, used in some build framework for embedded systems. This version was released in April 2011. I think support for stdalign.h was added in to GCC in version 4.7.0, released one year later, March 2012.
I'm not that surprised that people doing embedded systems are sometimes using pretty old tool chains. I'm also told that Microsoft's C compiler didn't get stdalign.h until 2019.
So my questions is: Are there others who are stuck with older compilers and getting trouble with Nettle's use of alignas/alignof? Is it somewhat common, or rather obscure?
It's possible to add a --disable-align configure option, but it would get a bit complex since that option must control what goes into the installed header files. So I wonder if that's worth the effort?
Regards, /Niels
Niels Möller nisse@lysator.liu.se writes:
It's possible to add a --disable-align configure option, but it would get a bit complex since that option must control what goes into the installed header files. So I wonder if that's worth the effort?
Did you consider using gnulib's align*/stdalign* modules?
/Simon
Simon Josefsson simon@josefsson.org writes:
Did you consider using gnulib's align*/stdalign* modules?
No, I wasn't aware of that. (I did use the somewhat related thing AX_CREATE_STDINT_H, but figured it was no longer needed and deleted that usage a few years ago).
Does the gnulib module define align* in terms of gcc attributes, or does it define them as no-ops when they are missing?
I see a few complications:
* Whatever workarounds need to go into installed header files (since alignedness is part of the ABI), and it needs to work in the same way with any reasonable compiler the user may have. With AX_CREATE_STDINT_H, nettle used to create and install a header <nettle/nettle-stdint.h>, so adding a <nettle/nettle-align.h> would be similar.
* If at configure time, it is decided that alignas doesn't work and it is disabled, that is an ABI break. That's not a show stopper, but needs to be clearly documented (a bit similar to --enable-mini-gmp), and should not be automatic. Disabling alignas will also make the ABI incompatible with a few of the assembly files, which would then need to be disabled too.
* If one attempts workarounds like
#define alignas(t) __attribute__((__aligned__(t)))
then location of alignas on declarations likely gets more brittle. I'm still a bit confused as to the requirements, but to me it appears that in order to support C++ (a requirement for nettle headers), alignas has to be placed early, like
alignas(uint64_t) char foo[17];
while an __attribute__ is usually placed late,
char foo[17] __attribute__(...);
Unless one-location-to-rule-them-all is found, one may need hacks like
ALIGNAS_BEFORE(uint64_t) char foo[17] ALIGNAS_AFTER(uint64_t);
with macros defined differently depending on __cplusplus. Doable, but not pretty.
Is gnulib addressing some or all of these issues?
So what I'm trying to figure out is, what's a good portability/complexity tradeoff. At the moment, I'm leaning towards requiring stdalign.h, and users stuck with compilers that don't support that would then need to patch out usage.
(Side note: AX_CREATE_STDINT_H used to work pretty well, I can only recall one issue. I may remember details wrong, but on Solaris N, stdint.h was missing, and nettle-stdint.h had to define all the standard types. But the definition of some of the types, like uint_fast32_t, was incompatible with the stdint.h that appeared in Solaris (N+1), causing errors for some users).
Regards, /Niels
I'm sorry for the delayed answer.
I'm undecided, I'm trying to understand how common this need is. A configure option is certainly possible, but a bit complex since it has to control what goes into the installed header files. I understand.
I reached out to our sysadm, and your message and my reply has been deleted from the archive. (Then there are other archives out there. E.g., https://mail-archive.com/nettle-bugs@lists.lysator.liu.se/msg03995.html. Looks like your email address is obfuscated so far that one has to click the "reply via email" button, and one then gets back a mailto:-link with your email address). Thank you for the effort.
So my questions is: Are there others who are stuck with older compilers and getting trouble with Nettle's use of alignas/alignof? Is it somewhat common, or rather obscure? That's for sure guaranteed, after version 4.0 release i had the issue happening on all seven, mips, arm, powerpc and arc.
It's possible to add a --disable-align configure option, but it would get a bit complex since that option must control what goes into the installed header files. So I wonder if that's worth the effort? If you think it not worth the trouble i perfectly understand and i'll go back to the older 3.10.2 version.
Regards, João Gomes
On Monday, February 9th, 2026 at 7:40 PM, Niels Möller nisse@lysator.liu.se wrote:
Niels Möller nisse@lysator.liu.se writes:
João Gomes writes:
In file included from nettle-meta.h:37:0, from non-nettle.h:38, from non-nettle.c:43: nettle-types.h:70:3: error: expected specifier-qualifier-list before ‘_Alignas’ In file included from ocb.h:38:0, from non-nettle.h:39, from non-nettle.c:43: aes.h:71:3: error: expected specifier-qualifier-list before ‘_Alignas’ aes.h:92:3: error: expected specifier-qualifier-list before ‘_Alignas’ aes.h:113:3: error: expected specifier-qualifier-list before ‘_Alignas’ make[1]: *** [Makefile:322: non-nettle.o] Error 1
Related to this note in NEWS:
In addition, support for alignof and alignas is required; these are part of C11, but intention is that this is the only required C11 feature.
For your information, I can compile it without any errors on x86-x64, but not on ARM anymore.
Which compiler and compiler options did you have this problem with? It's somewhat odd that you appear to have stdalign.h, and a macro alignas expanding to _Alignas, but the latter not working as expected.
Apparently, this was with gcc-4.5.3, used in some build framework for embedded systems. This version was released in April 2011. I think support for stdalign.h was added in to GCC in version 4.7.0, released one year later, March 2012.
I'm not that surprised that people doing embedded systems are sometimes using pretty old tool chains. I'm also told that Microsoft's C compiler didn't get stdalign.h until 2019.
So my questions is: Are there others who are stuck with older compilers and getting trouble with Nettle's use of alignas/alignof? Is it somewhat common, or rather obscure?
It's possible to add a --disable-align configure option, but it would get a bit complex since that option must control what goes into the installed header files. So I wonder if that's worth the effort?
Regards, /Niels
-- Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677. Internet email is subject to wholesale government surveillance.
nettle-bugs@lists.lysator.liu.se