有什么方法可以在SunOS上检测SparcWorks吗?

问题描述 投票:0回答:1

我有一个遗留的 C++ 代码库,其中包括以下内容:

// 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*

显然这是古代 C 的一些遗留物。注释后面是原型(在 Fedora Linux 39 上是错误的,它们与 glibc-2.38-18 的冲突)。我想把那部分彻底地

#if
去掉。有什么宏可以用吗?

c++ c sun
1个回答
0
投票

您可以尝试使用两者这些宏:

  • __SUNPRO_CC
    (对于 C++)或
    __SUNPRO_C
    (对于 C),这是通常由 SparcWorks 编译器定义的预定义宏;
  • __sun
    ,这是一个预定义的宏,通常由 SunOS 平台定义。
#if defined(__SUNPRO_CC) && defined(__sun)
// Specific code for SparcWorks compiler on SunOS
#else
// Add code for other compilers or platforms
#endif

也许有用的参考

© www.soinside.com 2019 - 2024. All rights reserved.