warnings when using cctype and tolower.

Lars Gullik Bjønnes larsbj@lyx.org
Mon Oct 25 08:45:00 GMT 1999


Benjamin Kosnik <bkoz@cygnus.com> writes:

| > When using tolower and compiling with -ansi -pedantic -Wall I get a
| > lot of warnings about "brace groups" not beeing allowed in
| > expressions.
| 
| ? 
| 
| Can you be a bit more specific please, about what you are trying to
| compile? If you post actual code, then others can try to reproduce your
| error.
| 
| -benjamin

Sure, just anything with tolower in it and when compiling with "-ansi
-pedantic -Wall -O"

f.ex:

inline int compare_no_case(string const & s, string const & s2)
{
        string::const_iterator p = s.begin();
        string::const_iterator p2 = s2.begin();
 
        while (p != s.end() && p2 != s2.end()) {
                if (tolower(*p) != tolower(*p2))
                        return (tolower(*p) < tolower(*p2)) ? -1 : 1;
                ++p;
                ++p2;
        }
 
        return s.size() - s2.size();
}                

Some more looking into header found the problem in ctype.h 
where tolower is a macro that calls another macro __tobody which is
completely encapsulated inside a { } group.

When I rewrite __tobody to be an inline function the problem goes
away.

I see now that this is probably the wrong place for this but...

	Lgb


More information about the Libstdc++ mailing list