From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: Portable check for unportable <ctype.h> macro usage |
Date: | 2016-10-19 17:41:50 |
Message-ID: | 17554.1476898910@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Andres Freund <andres(at)anarazel(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Thom Brown | 2016-10-19 17:44:29 | Re: Patch: Implement failover on libpq connect level. |
Previous Message | Bruce Momjian | 2016-10-19 17:35:52 | Re: incorrect libpq comment |