[csw-maintainers] #ifdef's for solaris versions

Juraj Lutter wilbury at opencsw.org
Mon Sep 9 00:05:49 CEST 2013

On 09/08/13 23:51, Maciej (Matchek) Bliziński wrote:
> 2013/9/8 Riccardo Mottola <rmottola at opencsw.org>:
>> Hi,
>> On 09/07/13 17:57, Maciej (Matchek) Bliziński wrote:
>>> 2013/9/7 Riccardo Mottola <rmottola at opencsw.org>
>>>> Are there reliable #ifdef's for identifying solaris? and then, in case,
>>>> its versions? I need certain  workaround for solaris and, furthermore some
>>>> are needed only for solaris 8/9, but no longer in 10+. (I'm struggling with
>>>> the missing stdint.h and the incomplete inttypes.h)
>>> Why not have a ./configure test for the exact feature or bug you're
>>> interested in detecting, and an own #define?
>> First, not everything is easy to check, also these tests need to work on
>> non-solaris platforms. Perhaps you do have some ready tests?
>> The first problem is checking for stdint.h: that's easy, the alternative is
>> inttypes. But then checking for various macros, some of those are defined
>> "blank" on solaris 8/9, not just undefined. (MIN/MAX limits, PRTuPTR and
>> that kind of stuff).
> If you could describe here an example of a test that doesn't look
> easy, maybe someone would chime in with a hint. Is your code available
> to be viewed? If not, can you post a snippet that breaks?
>> Furthermore, configure is easy for a program, but more difficult to use for
>> a library, a Framework where you install headers, because you don't install
>> config.h, or at least so I understand it.
> It's possible. You do install config.h, giving it either a unique name
> such as project-config.h or putting it into a project-specific
> directory.
> http://www.openismus.com/documents/linux/building_libraries/building_libraries#installingheaders
> http://stackoverflow.com/questions/1810216/autoconf-where-does-config-h-go
> which links to:
> http://www.gnu.org/software/autoconf-archive/ax_prefix_config_h.html

To make long story short:

On Solaris, gcc and sunstudio(?) #defines "sun" and gcc defines also
"__sun" so

#if defined(sun) || defined(__sun)

will compile block on Solaris plarform.

More information:

Juraj Lutter <wilbury at opencsw.org>

More information about the maintainers mailing list