[cfe-dev] clang and gcc implement __PRETTY_FUNCTION__ differently

Chandler Carruth chandlerc at google.com
Wed Nov 30 18:29:22 PST 2011


On Wed, Nov 30, 2011 at 6:21 PM, Kostya Serebryany <kcc at google.com> wrote:

> Hi,
> Here is one difference between clang and gcc which makes some of our
> software fail when built with clang.
> is this something you would consider fixing?
>
> Thanks,
>
> --kcc
>
> % cat pretty.cc
> #include <stdio.h>
> template<class T>
> const char *foo() {
>   return __PRETTY_FUNCTION__;
> }
> int main() {
>   printf("%s\n", foo<int>());
> }
> % g++ pretty.cc && ./a.out
> const char* foo() [with T = int]
>

I'm of two minds here. I think it would be great to include the template
arguments for the instantiation into the pretty name... But I'm really
worried about trying to chase the exact formatting used by GCC.

>From what I can tell, this is the format used in their diagnostic printing.
I would expect that to change on the GCC end as well, so it seems that any
code depending on this is just a time bomb...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111130/107e9096/attachment.html>


More information about the cfe-dev mailing list