Re: Portable check for unportable macro usage

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Portable check for unportable macro usage
Дата
Msg-id 17554.1476898910@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Portable check for unportable macro usage  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> Hm. I'd be kind of inclined to instead do something akin to

> #include <ctype.h>
> #define system_isupper(c) isupper(c)
> #undef isupper

Note that that doesn't do what you are probably thinking it does.

What is actually happening there, I believe, is that you're forcing
a fallback to the plain-function definition of isupper().  Ralph's
proposal accomplishes the same thing less messily by parenthesizing
the new macro's reference to isupper.  But in either case, we're
disabling any possible macro optimization in <ctype.h>, which makes
me not want to say it's something we'd enable unconditionally.

> #define isupper(c) (AssertVariableIsOfTypeMacro(c, unsigned char), isupper(c))
> =>
> /home/andres/src/postgresql/src/include/c.h:745:7: error: static assertion failed: "c does not have type unsigned
char"

Not sure we really want that; it breaks the standard-intended usage
of applying these functions to the result of getc().  It might be
all right for the core code, but I could see third-party authors
getting pretty upset with us for unilaterally imposing non-POSIX
semantics on these functions.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: incorrect libpq comment
Следующее
От: Thom Brown
Дата:
Сообщение: Re: Patch: Implement failover on libpq connect level.