Bug in manual for gcc-2.95: __FUNCTION__

Niels Möller nisse@lysator.liu.se
Sun Oct 3 14:10:00 GMT 1999


I miss some information about the predefined __FUNCTION__ variable
(Node: Function Names). I'd like to know the storage class, and the
precise type, of this variable.

In particular, I'd like to know that it is static const char *.
If it were, then I could use the following trick:

  struct c_context {
    const char *file;
    unsigned line;
    const char *function;
  };
  
  #define C_CONTEXT(name) \
  static const struct c_context \
  name = { __FILE__, __LINE__,__FUNCTION__ }
  
  struct bar *foo(void)
  {
    C_CONTEXT(here);
    return create_a_bar_with_a_reference_to_its_creator(&here);
  }

which would be an efficient way to install information for debugging
purposes into various objects.

So I'd like to propose that

(i) Information about the type and storage class of __FUNCTION__ be
    added to the manual.
(ii) If for some reason that is not already the case, the type and
     storage class be changed to static const char *.

Best regards,
/Niels Möller


More information about the Gcc-bugs mailing list