This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH v2] New mechanism for declaring const-covariant string functions.
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Zack Weinberg <zackw at panix dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 21 Nov 2016 22:06:55 -0800
- Subject: Re: [PATCH v2] New mechanism for declaring const-covariant string functions.
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com>
Zack Weinberg wrote:
This patch absorbs the entire mess into a pair of macros,
__CONST_COV_PROTO and __CONST_COV_BUILTIN, which are far less
error-prone to use, and which make the public header files much nicer
to read, too.
That is a impressive use of the C preprocessor.
Question: if I get the types wrong with a C or C++ program, what do the
resulting diagnostics look like? For this invalid program:
foo (int *x, int p)
return strchr (x, p);
I currently get a diagnostic that ends like this:
/usr/include/string.h:231:14: note: expected ‘const char *’ but argument is
of type ‘int *’
extern char *strchr (const char *__s, int __c)
and this is is reasonably easy to follow in isolation. Would it be as easy to
follow with the proposed patch? (Similarly for C++.)