[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: color in subwindows

From: Thomas Dickey
Subject: Re: color in subwindows
Date: Tue, 17 Jun 2003 06:27:26 -0400
User-agent: Mutt/1.3.28i

On Mon, Jun 16, 2003 at 08:46:46PM -0600, D. Stimits wrote:
> I'm still experimenting with this, I'm convinced I'm doing something wrong.
> >
> >
> > >PS: What are the chances that the wprintw family can be fixed to keep
> > >the fmt const char* instead of just char*? I know curses.h says they are
> > >const, but the actual functions are throwing the const away (according
> >
> >
> > that seems to be a matter of interpretation.  I added an extension (an
> > option to the configure script) which compiles-in "const" in the places
> > where I thought it should have been.  But that's not compatible with
> > X/Open curses - so it's not standard (it's fairly easy to construct
> > a program that will then compile only with ncurses - I've done it
> > accidentally more than once ;-).
> Basically, if a parameter to a function is not going to be modified, it 
> should be const in the function declaration. From the man page, and from 
> the curses.h  file, it claims it is const already for the fmt parameter:

I missed some of those (people report a few each year).
>    int printw(const char *fmt, ...);
>    int wprintw(WINDOW *win, const char *fmt, ...);
>    int mvprintw(int y, int x, const char *fmt, ...);
>    int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...);
>    int vwprintw(WINDOW *win, const char *fmt, va_list varglist);
>    int vw_printw(WINDOW *win, const char *fmt, va_list varglist);

here's the reference:

                 The Single UNIX ? Specification, Version 2
                      Copyright ? 1997 The Open Group


     printw - print formatted output in the current window


#include <curses.h>

int printw(char *fmt, ...);


     Refer to mvprintw().

            UNIX ? is a registered Trademark of The Open Group.
                      Copyright ? 1997 The Open Group
              [ Main Index | XSH | XCU | XBD | XCURSES | XNS ]

> However, the library file itself did not have const in the actual 
> implementation. Making fmt const in the ncurses functions will not break 
> or invalidate this against any other implementation at all, it can only 

I don't agree.  My understanding is that it's fairly likely that this is true,
but not 100%, since the C/C++ implementation is free to put const data into
a different address range.  And as I noted, I've found that relying on the
const behavior can break compatbility (for C anyway - I've had to modify
ded a couple of times to ensure it can build with ncurses with/without
NCURSES_CONST, as well as Solaris curses).

> help in cases where compilers enforce const, since ncurses does not 
> alter the fmt argument anyway. Here is a sample that does nothing, but 
> will fail to compile under g++, as the c_str() member of a std::string 
> is const, and g++ does not like passing it to a non-const parameter:

without a cast, at any rate (casts are ugly, of course).

Thomas E. Dickey <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]