This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: __builtin_types_compatible_p and 'char *' vs. 'char []'
Matthew Woehlke wrote:
> static inline s_or(char* a, char* b) {
> return ast_strlen_zero(a) ? b ? a);
> }
> static inline s_or_const(const char* a, const char* b) {
> return ast_strlen_zero(a) ? b ? a);
> }
> #define S_OR(a,b) \
> __builtin_choose_expr( \
> __builtin_types_compatible_p(typeof(a), char*) && \
> __builtin_types_compatible_p(typeof(b), char*), \
> s_or(a,b), s_or_const(a,b))
Unfortunately the documentation says the 'compatible determination
ignores attributes like const, volatile, etc. I'll give it a try though,
it's easy enough to test.
--
Kevin P. Fleming
Director of Software Technologies
Digium, Inc. - "The Genuine Asterisk Experience" (TM)