[cfe-dev] incompatible redeclaration of library function

Eli Friedman eli.friedman at gmail.com
Tue Jun 30 16:22:36 PDT 2009


On Tue, Jun 30, 2009 at 8:26 AM, Henrique Almeida<hdante at gmail.com> wrote:
>  This is almost good to me, however there are some parts of the
> library (ie, in printf) that require the use of the equivalent signed
> version of size_t (for example, to print the argument "%zd"). Is there
> a way to get this in clang ? Else, I'll have to define size_t in per
> case basis. Same for ptrdiff_t.

Ah... that's kind of messy.  If you make the assumption that size_t
and ptrdiff_t are either short, int, long, or long long, you can
probably pull it off with a combination of typeof,
__builtin_choose_expr, and __builtin_types_compatible_p.

>  Also, what's the expected behavior of redefining a built-in function ?

Redeclaring a built-in function with a compatible prototype is okay.
If you need to define library functions, you should pass in
-fno-builtin on the command-line.

-Eli




More information about the cfe-dev mailing list