[Rd] Use of __FUNCTION__ and__PRETTY_FUNCTION__ is not portable

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Aug 8 09:25:10 CEST 2007

These are C/C++ extensions found in several packages[1].  They are 
non-standard: the C99 standard has __func__ which should be used in C in 
place of either.  If you really want back compatibilty, try something like

#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
#  define __func__ __FUNCTION__
# else
#  define __func__ "<unknown>"
# endif

I don't know a portable equivalent in C++, but I do know that some non-GNU 
C++ compilers do not support these, so they should be conditionalized on
__GNUC__  (or tested for by configure).  For example, SunPro C++ supports 
__func__ as a (non-default) extension:


so probably configure should be used to test what is available.

[1] GOSim MCMCpack MasterBayes RGtk2 rcom smoothSurv

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-devel mailing list