This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] New mechanism for declaring const-covariant string functions.


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:

  #include <string.h>
  char *
  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++.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]