On Tue, 19 Aug 2025 at 16:02, Marek Knápek <knapek.mar+...@gmail.com> wrote:
> You could always align your struct to particular alignment, > even in C89. But that alignment must be alignment of one of > already existing types. Typically such as void* or double. > > > #include <assert.h> > #include <stdint.h> /* uintptr_t might not exist here in C89 */ > > union aligned_char_u > { > char m_char; > void* m_pointer; > }; > typedef union aligned_char_u aligned_char_t; > > struct my_char_s > { > aligned_char_t m_char; > }; > typedef struct my_char_s my_char_t; > > > int main(void) > { > my_char_t my_char; > > assert(((uintptr_t)(&my_char.m_char.m_char)) % (sizeof(void*)) == 0); > > my_char.m_char.m_char = '!'; > return my_char.m_char.m_char; > } > > > > Even with the existing workaround I think this would fit well in C89 and replace TCC __attribute__ usage in this case with a portable syntax that does not require macros or C89 workaround.
_______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel