Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Issue 1558333002: Rectify our use of std::nullptr_t, inclusions of <stddef.h>/<cstddef>. (Closed)

Created:
4 years, 11 months ago by viettrungluu
Modified:
4 years, 11 months ago
Reviewers:
jamesr
CC:
Aaron Boodman, abarth-chromium, ben+mojo_chromium.org, darin (slow to review), gregsimon, mojo-reviews_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+mojopublicwatch_chromium.org
Base URL:
https://github.com/domokit/mojo.git@master
Target Ref:
refs/heads/master
Project:
mojo
Visibility:
Public.

Description

Rectify our use of std::nullptr_t, inclusions of <stddef.h>/<cstddef>. (Convert uses of decltype(nullptr) to std::nullptr_t. Include <cstddef> where we use std::nullptr_t. Include <stddef.h> for unqualified size_t.) In general, you want to include <X.h>, not <cX>: * <cX> need only declare/define things in the std namespace and not things in the global namespace (even if in practice it often does). * (Thus <cX> need not declare/define POSIX extensions declared by <X.h> at all, in any namespace.) So unless you want to write std::size_t, std::fopen(), etc., you want <X.h>. A weird case is nullptr_t/std::nullptr_t. C++11 decrees that <stddef.h> define (::)nullptr_t, even though it's a C++ language feature (note that it need not define std::nullptr_t at all). So in theory one should be able to just include <stddef.h> and use nullptr_t (in the global namespace). Unfortunately, AFAICT, gcc+libstdc++ and clang+libc++ appear to have different philosophies here. gcc's <stddef.h> just defines nullptr_t, so libstdc++ doesn't have its own <stddef.h>. clang's <stddef.h> does NOT define nullptr_t, so libc++ has its own <stddef.h> that defines nullptr_t (and which then does an #include_next <stddef.h>, picking up the compiler's <stddef.h>). Thus including <stddef.h> with clang+libstdc++ does NOT result in nullptr_t being defined (at least on Linux currently). :-( So we use std::nullptr_t and include <cstddef>. Note that sometimes we also do the right thing and ALSO include <stddef.h> (so that we can use size_t unqualified). R=jamesr@chromium.org Committed: https://chromium.googlesource.com/external/mojo/+/a6a56396e8ce30e46fa2f391476dcaf586c04344

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+17 lines, -18 lines) Patch
M mojo/converters/input_events/input_events_type_converters.cc View 1 chunk +0 lines, -2 lines 0 comments Download
M mojo/edk/util/command_line.h View 1 chunk +2 lines, -1 line 0 comments Download
M mojo/edk/util/make_unique.h View 1 chunk +2 lines, -1 line 0 comments Download
M mojo/edk/util/ref_counted.h View 1 chunk +0 lines, -5 lines 0 comments Download
M mojo/edk/util/ref_ptr.h View 1 chunk +1 line, -1 line 0 comments Download
M mojo/icu/constants.h View 1 chunk +1 line, -1 line 0 comments Download
M mojo/public/cpp/bindings/array.h View 2 chunks +2 lines, -1 line 0 comments Download
M mojo/public/cpp/bindings/interface_ptr.h View 3 chunks +3 lines, -2 lines 0 comments Download
M mojo/public/cpp/bindings/interface_request.h View 3 chunks +4 lines, -2 lines 0 comments Download
M mojo/public/cpp/bindings/struct_ptr.h View 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 5 (1 generated)
viettrungluu
4 years, 11 months ago (2016-01-06 01:04:38 UTC) #1
jamesr
lgtm
4 years, 11 months ago (2016-01-06 01:07:54 UTC) #2
jamesr
If we run into trouble we can go back to decltype(nullptr)
4 years, 11 months ago (2016-01-06 01:08:10 UTC) #3
viettrungluu
4 years, 11 months ago (2016-01-06 21:25:02 UTC) #5
Message was sent while issue was closed.
Committed patchset #1 (id:1) manually as
a6a56396e8ce30e46fa2f391476dcaf586c04344 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698