Page MenuHomePhabricator

Remove ::gets for FreeBSD 13 and later

Authored by dim on Sep 7 2019, 5:09 AM.



In @emaste removed gets() from
FreeBSD 13's libc, and our copies of libc++ and libstdc++. In that change, the
declarations were simply deleted, but I would like to propose this conditional
test instead.

Diff Detail


Event Timeline

dim created this revision.Sep 7 2019, 5:09 AM
emaste added a comment.Sep 7 2019, 5:33 AM

LGTM from the FreeBSD perspective.

mclow.lists added a comment.EditedSep 7 2019, 6:55 AM

I'm wondering if this has become complicated enough that we should define a _LIBCPP_C_HAS_NO_GETS config macro.

Then the code in cstdio becomes:

#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS)
using ::gets;

which I think is much clearer, and captures the intent
We do not import gets into namespace std when:

  • It does not exist in the underlying C library, or
  • We are compiling for C++14 or later.
This comment was removed by mclow.lists.
dim updated this revision to Diff 219245.Sep 7 2019, 8:19 AM

Add _LIBCPP_C_HAS_NO_GETS macro to <__config>, and use that in <cstdio>.

mclow.lists accepted this revision.Sep 7 2019, 12:51 PM

LGTM with the one change I suggested.

1147 ↗(On Diff #219245)

Even better would be to have a way to define it at build time as well.

So wrap this in


and then commit it.

This revision is now accepted and ready to land.Sep 7 2019, 12:51 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 7 2019, 3:17 PM