how can I get the call __PRETTY_FUNCTION__ runing?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas

    how can I get the call __PRETTY_FUNCTION__ runing?

    Hello im using Visual Studio .net

    And have troubel with the following line

    ClassA::~ClassA ()
    {
    cerr<<__PRETTY_ FUNCTION__<<"\n "; \\this works with g++
    }

    on compiling I get this back:
    filename.cc(20) : error C2065: '__PRETTY_FUNCT ION__' : undeclared identifier

    does exist an library to add or have I just missed an command?
    Thanks for your Help!
  • Rolf Magnus

    #2
    Re: how can I get the call __PRETTY_FUNCTI ON__ runing?

    Thomas wrote:
    [color=blue]
    > Hello im using Visual Studio .net
    >
    > And have troubel with the following line
    >
    > ClassA::~ClassA ()
    > {
    > cerr<<__PRETTY_ FUNCTION__<<"\n "; \\this works with g++
    > }
    >
    > on compiling I get this back:
    > filename.cc(20) : error C2065: '__PRETTY_FUNCT ION__' : undeclared
    > identifier
    >
    > does exist an library to add or have I just missed an command?
    > Thanks for your Help![/color]

    You have missed the fact that __PRETTY_FUNCTI ON__ is not part of
    standard C++ and thus may not be available on every compiler.

    Comment

    • Peter van Merkerk

      #3
      Re: how can I get the call __PRETTY_FUNCTI ON__ runing?

      > Hello im using Visual Studio .net[color=blue]
      >
      > And have troubel with the following line
      >
      > ClassA::~ClassA ()
      > {
      > cerr<<__PRETTY_ FUNCTION__<<"\n "; \\this works with g++
      > }
      >
      > on compiling I get this back:
      > filename.cc(20) : error C2065: '__PRETTY_FUNCT ION__' : undeclared[/color]
      identifier[color=blue]
      >
      > does exist an library to add or have I just missed an command?[/color]

      __PRETTY_FUNCTI ON__ is not part of standard C++ but a g++ specific
      extension. Consequently you cannot expect every compiler to support
      this. If you are satisfied with just file name and line number you might
      use a macro like this:

      #define PRETTY_FUNCTION __FILE__":" << __LINE__

      The predefined macro __FILE__ and __LINE__ are defined in the C++
      standard, and should be available on any reasonable compilant C++
      compiler. Note that this macro is not an exact equivalent for the
      __PRETTY_FUNCTI ON__ macro; it only works for stream output. With a bit
      more effort it can be modified to produce a string.

      --
      Peter van Merkerk
      peter.van.merke rk(at)dse.nl




      Comment

      Working...