svn commit: r300824 - head/lib/libmd

Conrad Meyer cem at FreeBSD.org
Fri May 27 07:53:35 UTC 2016


There's nothing to support — literally ignoring the keyword is an
acceptable implementation.  So it's disappointing C++ chooses to
reject C keywords.

My take is that C++ programs shouldn't be including sys/md5.h directly
at all.  That's the kernel's header.  If they want to use md5, they go
through libmd like everyone else.  So it doesn't matter too much to me
whether the wrapping happens in libmd md5.h or sys/md5.h.

If sys/md5.h includes a static inline function, there are bigger
problems with potentially trying to interpret C code as C++.  Frankly,
C++ is not a C dialect anymore.  They happen to share a bare bones
assemblerish ABI but other than that they are diverging.

Your proposed macro seems ok, although it is pretty long for where it
would be used.  Maybe __min_size()?

Best,
Conrad



On Thu, May 26, 2016 at 11:35 PM, Ed Schouten <ed at nuxi.nl> wrote:
> Hi Conrad,
>
> 2016-05-27 7:31 GMT+02:00 Conrad E. Meyer <cem at freebsd.org>:
>>   libmd: Work around C++'s inability to understand C
>
> So C++ doesn't support using 'static' within array types, right? What
> I personally dislike about this specific change:
>
> - Including <sys/md5.h> directly still doesn't work.
> - If <sys/md5.h> is ever going to include a 'static inline' function,
> the static keyword would also be stripped off.
>
> Would it make sense to come up with a macro in <sys/cdefs.h> to deal with this?
>
> #if defined(__cplusplus) || defined(ancient compiler)
> #define __minimum_size(n) n
> #else
> #define __minimum_size(n) static (n)
> #endif
>
> That way we can annotate this everwhere we'd want, without needing to
> care about compiler versions, languages, etc.
>
> --
> Ed Schouten <ed at nuxi.nl>
> Nuxi, 's-Hertogenbosch, the Netherlands
> KvK-nr.: 62051717


More information about the svn-src-head mailing list