Page MenuHomeFreeBSD

assert(3): Update with _Static_assert
ClosedPublic

Authored by kfv_kfv.io on Apr 19 2021, 10:50 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 23, 7:10 AM
Unknown Object (File)
Thu, Mar 21, 7:07 AM
Unknown Object (File)
Sun, Mar 17, 5:14 PM
Unknown Object (File)
Feb 9 2024, 9:57 AM
Unknown Object (File)
Jan 4 2024, 3:58 AM
Unknown Object (File)
Dec 31 2023, 12:22 PM
Unknown Object (File)
Dec 25 2023, 9:34 AM
Unknown Object (File)
Dec 20 2023, 5:56 AM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 38689
Build 35578: arc lint + arc unit

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.