Page MenuHomeFreeBSD

Fix makefs bootstrap on macOS after D25563
ClosedPublic

Authored by arichardson on Aug 3 2020, 2:40 PM.

Details

Summary

The macOS assert.h header does not define static_assert when compiling in
C99 mode. To fix this compile with -std=c11.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

arichardson created this revision.

I'm not sure but if I'm reading it right:

#ifndef __cplusplus
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define static_assert _Static_assert
#endif /* __STDC_VERSION__ */
#endif /* !__cplusplus */

It's basically saying, if we are not compiling for C++ and if -std=c11 was used, static_assert is defined as an alias of _Static_assert? Will saying CSTD=c11 fix this on macOS?

I'm not sure but if I'm reading it right:

#ifndef __cplusplus
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define static_assert _Static_assert
#endif /* __STDC_VERSION__ */
#endif /* !__cplusplus */

It's basically saying, if we are not compiling for C++ and if -std=c11 was used, static_assert is defined as an alias of _Static_assert? Will saying CSTD=c11 fix this on macOS?

Yeah using C11 should also fix it since C11 requires assert.h to define static_assert.

emaste added a subscriber: emaste.

I'd slightly prefer compiling as C11 and spelling it the sensible (static_assert) way, but either way is acceptable to me.

This revision is now accepted and ready to land.Aug 21 2020, 11:40 PM
This revision now requires review to proceed.Aug 24 2020, 10:05 AM

As an aside, we should put CSTD in style.Makefile(5). Looking at a few other examples this order seems to be common -- WARNS, CSTD, CFLAGS

This revision is now accepted and ready to land.Aug 24 2020, 12:45 PM

As an aside, we should put CSTD in style.Makefile(5). Looking at a few other examples this order seems to be common -- WARNS, CSTD, CFLAGS

I searched for CSTD and it seems most uses are after WARNS, so I did the same here. I wasn't aware of style.Makefile(5) but if you'd like I can add CSTD between warns and CFLAGS?

I searched for CSTD and it seems most uses are after WARNS, so I did the same here. I wasn't aware of style.Makefile(5) but if you'd like I can add CSTD between warns and CFLAGS?

Sure, I think it'd be fine to make that change to style.Makefile.

This revision was automatically updated to reflect the committed changes.