Gcc, Solaris and putchar() problems

On solaris with gcc-4.3.1, the macro __cplusplus is not defined to
199711L. This is a long-standing issue with solaris. This doesn't much
matter on some platforms, but for matplotlib, what is happening to me
is that through a series of defines and conditionals, the method
putchar, as used here:

./ttconv/ttutil.cpp:void TTStreamWriter::putchar(int val)

gets tokenized by the preprocessor into putc by
/usr/include/iso/stdio_iso.h, here on line 350:

#define putchar(x) putc((x), stdout)

This only happens if __cplusplus is < 199711L. I'm avoiding this by
building using the studio C compiler, but I thought I'd mention this
in case it's possible to detect this during the configuration stage,
and perhaps wrap with something like:

#ifdef
#if __cplusplus <= 199711L
#undef putchar
#endif
#endif

However, I haven't tested this yet. Has anyone else thought about
this?

Thanks,

-Peter

···

--
The 5 year plan:
In five years we'll make up another plan.
Or just re-use this one.

(Sorry for the delay, just back from vacation).

I don't have access to that version of gcc on Solaris to test. However, if you find a preprocessor workaround that works for you, I'm happy to test it on Linux/Mac/Windows and commit.

Cheers,
Mike

Peter C. Norton wrote:

···

On solaris with gcc-4.3.1, the macro __cplusplus is not defined to
199711L. This is a long-standing issue with solaris. This doesn't much
matter on some platforms, but for matplotlib, what is happening to me
is that through a series of defines and conditionals, the method
putchar, as used here:

./ttconv/ttutil.cpp:void TTStreamWriter::putchar(int val)

gets tokenized by the preprocessor into putc by
/usr/include/iso/stdio_iso.h, here on line 350:

#define putchar(x) putc((x), stdout)

This only happens if __cplusplus is < 199711L. I'm avoiding this by
building using the studio C compiler, but I thought I'd mention this
in case it's possible to detect this during the configuration stage,
and perhaps wrap with something like:

#ifdef
#if __cplusplus <= 199711L
#undef putchar
#endif

However, I haven't tested this yet. Has anyone else thought about
this?

Thanks,

-Peter

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Michael,

I'm going to see if there is a fixincludes route to fixing this, but
in case there isn't, is adding an additional name to the
TTStreamWriter, eg. TTStreamWriter::put_char, out of the question?

Thanks,

-Peter

···

On Thu, Jul 31, 2008 at 09:08:18AM -0400, Michael Droettboom wrote:

(Sorry for the delay, just back from vacation).

I don't have access to that version of gcc on Solaris to test. However,
if you find a preprocessor workaround that works for you, I'm happy to
test it on Linux/Mac/Windows and commit.

Cheers,
Mike

Peter C. Norton wrote:
>On solaris with gcc-4.3.1, the macro __cplusplus is not defined to
>199711L. This is a long-standing issue with solaris. This doesn't much
>matter on some platforms, but for matplotlib, what is happening to me
>is that through a series of defines and conditionals, the method
>putchar, as used here:
>
>./ttconv/ttutil.cpp:void TTStreamWriter::putchar(int val)
>
>gets tokenized by the preprocessor into putc by
>/usr/include/iso/stdio_iso.h, here on line 350:
>
>#define putchar(x) putc((x), stdout)
>
>This only happens if __cplusplus is < 199711L. I'm avoiding this by
>building using the studio C compiler, but I thought I'd mention this
>in case it's possible to detect this during the configuration stage,
>and perhaps wrap with something like:
>
>#ifdef
>#if __cplusplus <= 199711L
>#undef putchar
>#endif
>#endif
>
>However, I haven't tested this yet. Has anyone else thought about
>this?
>
>Thanks,
>
>-Peter
>
>
>
>
>

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

--
The 5 year plan:
In five years we'll make up another plan.
Or just re-use this one.

I assume you mean renaming TTStreamWriter::putchar to TTStreamWriter::put_char. That would be fine. Once you confirm that solves your problem on Solaris, I'll test and commit it here.

Cheers,
Mike

Peter C. Norton wrote:

···

Michael,

I'm going to see if there is a fixincludes route to fixing this, but
in case there isn't, is adding an additional name to the
TTStreamWriter, eg. TTStreamWriter::put_char, out of the question?

Thanks,

-Peter

On Thu, Jul 31, 2008 at 09:08:18AM -0400, Michael Droettboom wrote:
  

(Sorry for the delay, just back from vacation).

I don't have access to that version of gcc on Solaris to test. However, if you find a preprocessor workaround that works for you, I'm happy to test it on Linux/Mac/Windows and commit.

Cheers,
Mike

Peter C. Norton wrote:
    

On solaris with gcc-4.3.1, the macro __cplusplus is not defined to
199711L. This is a long-standing issue with solaris. This doesn't much
matter on some platforms, but for matplotlib, what is happening to me
is that through a series of defines and conditionals, the method
putchar, as used here:

./ttconv/ttutil.cpp:void TTStreamWriter::putchar(int val)

gets tokenized by the preprocessor into putc by
/usr/include/iso/stdio_iso.h, here on line 350:

#define putchar(x) putc((x), stdout)

This only happens if __cplusplus is < 199711L. I'm avoiding this by
building using the studio C compiler, but I thought I'd mention this
in case it's possible to detect this during the configuration stage,
and perhaps wrap with something like:

#ifdef
#if __cplusplus <= 199711L
#undef putchar
#endif

However, I haven't tested this yet. Has anyone else thought about
this?

Thanks,

-Peter

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA