I've got a legacy C++ code base which includes the following:
// this kludge is required because SparcWorks 3.0.1 under SunOS
// includes malloc.h in stdlib.h, and misdeclares free() to take a char*,
// and malloc() and memalign() to return char*
Clearly this is some leftover from ancient C. The comment is followed by prototypes (wrong here on Fedora Linux 39, they clash with the ones glibc-2.38-18 has). I'd like to #if
that part out cleanly. Any macro that I can use?
You could try to use both these macros:
__SUNPRO_CC
(for C++) or __SUNPRO_C
(for C), which are macros typically defined by the SparcWorks compiler indicating the usage of Sun C/C++ compiler;__sun
, which is a macro defined by the SunOS platform, indicating the usage of the Sun compiler.#if defined(__SUNPRO_CC) && defined(__sun)
// Specific code for SparcWorks compiler on SunOS
#else
// Code for other compilers or platforms
#endif
Maybe useful reference: Sun™ Studio 12: C++ FAQ