Page MenuHomeFreeBSD

assert(3): Update with _Static_assert
ClosedPublic

Authored by kfv_kfv.io on Apr 19 2021, 10:50 AM.

Diff Detail

Repository
rG 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

Note: usually we try to avoid "you" in the documentation.

Also, I don't know much about static_assert. We may need a src committer help here.

Ah, I again made that mistake! Sorry :-(

share/man/man3/assert.3
102

I'd add an example too.

static_assert(sizeof(int) == sizeof(void *), "ints and pointers are different sizes");

  • assert(3): rephrase and remove the "your" determiner
share/man/man3/assert.3
102

Sure, I will update it shortly. Thanks.

  • assert(3): add an example for static_assert()
  • assert(3): add an example for static_assert()

Fixup!

kfv_kfv.io added inline comments.
share/man/man3/assert.3
102

I just added an example, please let me know if I should add more or change anything. Thanks!

This revision is now accepted and ready to land.Apr 19 2021, 10:01 PM
This revision was automatically updated to reflect the committed changes.
arichardson added inline comments.
share/man/man3/assert.3
90–91

Not sure if you also want to mention C++ here. This statement is only true for C, in C++11 static_assert is a keyword and _Static_assert. GCC rejects _Static_assert in C++ mode while clang accepts it.

share/man/man3/assert.3
90–91

Completely true. _Static_assert does not exist in C++, and that's why using static_assert is mostly preferred. And this is indeed very good to educate the reader. But I think we predominantly discuss C topics, and since a lot of things differ in C++, I think this is not necessary to delve into such details.