From: Ersek, Laszlo on
On Sun, 27 Jun 2010, Uno wrote:

> #define _XOPEN_SOURCE 500

> How can I tell whether these macros are doing anything for me?

Putting it differently: "how can I tell whether following standards does
anything for me?"

You can tell when you recompile the program on the n-th
standards-conformant platform, and still don't have to modify anything.

"The requirements of users of POSIX.1-2008 can be summarized as a single
goal: /application source portability/."

http://www.opengroup.org/onlinepubs/9699919799/xrat/V4_port.html#tag_24_01

This may not have been formulated that explicitly in earlier versions of
the SUS or POSIX (I'm too lazy to check now), but I'm sure the intent was
always the same.

Cheers,
lacos
From: Geoff Clare on
Ersek, Laszlo wrote:

> Prepend at least
>
> #define _XOPEN_SOURCE 500
>
> and if you use ENHANCED CURSES interfaces as well, then additionally
>
> #define _XOPEN_SOURCE_EXTENDED 1
>
> http://www.opengroup.org/onlinepubs/007908775/xcurses/implement.html

You've been misled by reading that page without also following the
Corrigendum U018 link at the top.

The text below the corrigendum link is actually from SUSv1 (which had
no HTML version). U018 amends it for a SUSv2 environment, including
changing the part about _XOPEN_SOURCE_EXTENDED to refer to
_XOPEN_SOURCE=500 instead.

> AIUI, there's no more recent formal standard than SUSv2 defining CURSES.

It was revised for SUSv4, although published about a year after the
SUSv4 Base Specifications (aka POSIX.1-2008). The new XCurses spec is
available from

http://www.opengroup.org/bookstore/catalog/c094.htm

--
Geoff Clare <netnews(a)gclare.org.uk>

From: Ersek, Laszlo on
On Tue, 29 Jun 2010, Geoff Clare wrote:

> Ersek, Laszlo wrote:
>
>> Prepend at least
>>
>> #define _XOPEN_SOURCE 500
>>
>> and if you use ENHANCED CURSES interfaces as well, then additionally
>>
>> #define _XOPEN_SOURCE_EXTENDED 1
>>
>> http://www.opengroup.org/onlinepubs/007908775/xcurses/implement.html
>
> You've been misled by reading that page without also following the
> Corrigendum U018 link at the top.

I did follow that link, but stopped skimming the linked-to page at the
first </hr>. Sorry for being superficial :(

This isn't really topical here, but let me ask: what is the policy on
(periodically) re-releasing standards with the accrued corrigenda
incorporated? It is very cumbersome to switch back and forth between the
main text and the latest cumulative corrigendum, and the strict "editing
commands" format of the corrigenda would otherwise allow for "easy"
merging.


> The text below the corrigendum link is actually from SUSv1 (which had no
> HTML version). U018 amends it for a SUSv2 environment, including
> changing the part about _XOPEN_SOURCE_EXTENDED to refer to
> _XOPEN_SOURCE=500 instead.
>
>> AIUI, there's no more recent formal standard than SUSv2 defining
>> CURSES.
>
> It was revised for SUSv4, although published about a year after the
> SUSv4 Base Specifications (aka POSIX.1-2008). The new XCurses spec is
> available from
>
> http://www.opengroup.org/bookstore/catalog/c094.htm

Instantly stashed.

Thank you very much!
lacos
From: Uno on
Ersek, Laszlo wrote:
> On Tue, 29 Jun 2010, Geoff Clare wrote:

>> http://www.opengroup.org/bookstore/catalog/c094.htm
>
> Instantly stashed.

Thanks for the heads up on the curses data, in particular, the pdf. How
can I make this a better program:

#define _XOPEN_SOURCE 500
//#define _XOPEN_SOURCE_EXTENDED 1
#include <stdio.h>
#include <curses.h>
int
tty_break ()
{
initscr ();
cbreak ();
return 0;
}

int
tty_getchar ()
{
return getch ();
}

int
tty_putchar(int d)
{
return printw("%c is, in decimal, %d\n", d, d);
}

int
tty_fix ()
{
endwin ();
return 0;
}

int
main (void)
{
char ch;
int e;
if (tty_break () != 0)
return 1;
while(1) /* yeah, I know... *//* yeah, I don't*/
{
ch = tty_getchar ();
if ((ch == 'p'))
break;
e = tty_putchar(ch);
printw("e is %d\n", e);
}
tty_fix ();
return 0;
}

// gcc -Wall -Wextra -lcurses p9.c -o out

--
Uno
From: Geoff Clare on
Ersek, Laszlo wrote:

> This isn't really topical here, but let me ask: what is the policy on
> (periodically) re-releasing standards with the accrued corrigenda
> incorporated?

I don't think there is a specific policy in the Open Group about this.
It was done for the SUSv3 Base Specifications (POSIX.1-2001) with TC1
(2003) and TC2 (2004), but that is a joint standard between the Open
Group, IEEE and ISO, so it might have been done because of policy
in either IEEE or ISO. XCurses is just an Open Group standard.

--
Geoff Clare <netnews(a)gclare.org.uk>