Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libcxx/include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ size_t strlen(const char* s);
# include_next <string.h>
# endif

# include <stddef.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about including <__cstddef/size_t.h> which looks smaller?

Suggested change
# include <stddef.h>
# include <__cstddef/size_t.h>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this file uses bare size_t instead of std::size_t, I think <stddef.h> is a corret header to include here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I don't think we can use __cstddef/size_t.h because it doesn't provide the right declaration (conceptually). In practice, of course, they're all the same type in the end.

This makes me wonder whether we should introduce an internal alias for decltype(sizeof(int)), something like __libcxx_size_t and then do namespace std { using size_t = ::__libcxx_size_t; }. However, until we have a reason to do that, I think including <stddef.h> here is fine.


// MSVCRT, GNU libc and its derivates may already have the correct prototype in
// <string.h>. This macro can be defined by users if their C library provides
// the right signature.
Expand Down
Loading