Page MenuHomeFreeBSD

tools/build/stddef.h: fix non-macos build
AcceptedPublic

Authored by vexeduxr on Mon, Feb 23, 5:37 AM.

Details

Reviewers
brooks
kib
Summary
Both clang and gcc's stddef.h are designed to be included multiple
times. If any of the __need_* macros are defined, only those types are
provided (e.g __need_size_t).

Remove the #pragma once, ptraddr_t is guarded by _PTRADDR_T_DECLARED
anyways.

Also use __SIZE_TYPE__ instead of size_t since it's not guaranteed to be
defined.

Edit: put commit message in a code block to avoid markdown shenanigans

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70899
Build 67782: arc lint + arc unit

Event Timeline

vexeduxr edited the summary of this revision. (Show Details)

Also use SIZE_TYPE instead of size_t since it's not guaranteed to be defined.

Where this happens? size_t in stddef.h is required by all C standards AFAIR.

It happens if anything other than __need_size_t is defined. Some headers include stddef.h but don't want the whole thing, so they define __need_*. The header can also be included multiple times with different __need_* macros defined.
This is all internal of course, simply including stddef.h with nothing defined gives you the whole thing.

A comment from clang's stddef.h:

This header is designed to be included multiple times. If any of the __need_
macros are defined, then only that subset of interfaces are provided. This
can be useful for POSIX headers that need to not expose all of stddef.h, but
need to use some of its interfaces. Otherwise this header provides all of
the expected interfaces.

This revision is now accepted and ready to land.Mon, Feb 23, 7:38 PM