Created attachment 200284 [details] Add missing macros for C++ linking While testing a new version of an application I ran into a linking error. It appears c++ sources including sys/random.h fail linking due to a missing reference to getrandom. This is caused by missing __BEGIN_DECLS/__END_DECLS in sys/random.h Supplied patch remedies the problem, but it might need review by a C++ guru (which I'm not).
The cdefs include isn't needed (it's in the wrong place, too, but it's redundant with the sys/types include already present in the right place at top of file). Otherwise, adding the C++ demangling seems reasonable to me — at least in the sense that it is consistent with other sys/ headers. For 12.0, can you work around the issue by adding 'extern "C" {' around the #include?
I can confirm adding extern "C" {} around it works fine. The software I was trying to build is still in alpha, so no immediate need for a proper fix. I am curious though. Will this be fixed in 12.0-RELEASE-p? update or only in 12-STABLE ? Thanks for your quick response.
I can't speak to that; I don't know much about FreeBSD's stable/releng process.
Created attachment 200452 [details] Add missing macros for C++ linking (new patch without cdefs.h include)
A commit references this bug: Author: cem Date: Mon Dec 24 19:37:10 UTC 2018 New revision: 342398 URL: https://svnweb.freebsd.org/changeset/base/342398 Log: Enable sys/random.h #include from C++ And bump __FreeBSD_version, just in case. PR: 234180 Submitted by: Ralf van der Enden <tremere AT cainites.net> MFC after: 5 days Changes: head/sys/sys/param.h head/sys/sys/random.h
Thanks! Ok, that's the CURRENT part; someone else will handle MFC'ing it into stable/12.
A commit references this bug: Author: brooks Date: Thu Jan 17 23:22:56 UTC 2019 New revision: 343126 URL: https://svnweb.freebsd.org/changeset/base/343126 Log: MFC r342398: Enable sys/random.h #include from C++ And bump __FreeBSD_version, just in case. PR: 234180 Submitted by: Ralf van der Enden <tremere AT cainites.net> Changes: _U stable/12/ stable/12/sys/sys/param.h stable/12/sys/sys/random.h
Merged to 12-STABLE.