bug-ncurses
[Top][All Lists]
Advanced

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

Re: attribute set datatype


From: Thomas Dickey
Subject: Re: attribute set datatype
Date: Tue, 24 Dec 2013 05:17:25 -0500
User-agent: Mutt/1.5.20 (2009-06-14)

On Mon, Dec 23, 2013 at 12:09:38PM -0500, Ruslan Nabioullin wrote:
> Hello,
> 
> What is the reason that the integral datatype used as an attribute
> set is signed in functions and macros consuming or returning the
> set? Obviously signedness is less elegant and leads to nonintuitive
> behavior when right-shifting.

That's because the prototypes for those were defined as such by X/Open

For ncurses, there's this chunk in the header which could be used to tweak 
warnings:

/*
 * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
 * configured using --disable-macros.
 */
#ifdef NCURSES_NOMACROS
#ifndef NCURSES_ATTR_T
#define NCURSES_ATTR_T attr_t
#endif
#endif /* NCURSES_NOMACROS */
 
> Furthermore, why is the datatype different in attribute definitions
> (unsigned)?  That essentially means that two different datatypes are
> used for the same intended datatype; although C is weakly-typed,
> compilers may emit a warning, such as in:
> 
> unsigned int msg_attributes;
> ...
> msg_attributes = color_available &&
>       init_pair(MSG_COLOR_PAIR, MSG_TEXT_COLOR, COLOR_BLACK) != ERR
>       ? COLOR_PAIR(MSG_COLOR_PAIR) : A_NORMAL;

The biggest source of warnings I recall from the macros is the (apparently
unavoidable) comparison of a pointer to null.

for the specific case, I do review and tweak the test programs to reduce
warnings.

> ...
> 
> -Ruslan
> 
> _______________________________________________
> Bug-ncurses mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-ncurses

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

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