tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: New feature-testing macros in <sys/cdefs.h>
Dennis Ferguson wrote:
> On 4 Feb, 2015, at 15:00 , Kamil Rytarowski <n54%gmx.com@localhost> wrote:
> > Any comments? Someone for or against of use of these macros?
> >
> > I'm about to propose a library for overflows, which reuses these symbols,
> > instead of depending on the hard-coded Clang checks.
> >
> > Every compiler is free to support this or that builtin,
> > without playing a role of GCC/Clang.
>
> It's a bit hard to have an opinion since I write code that I expect to
> be compiled with gcc at least as often as clang. I generally deal with
> this by trying to only use features that I expect both clang and gcc to
> support, which probably means I wouldn't use those macros since only clang
> really supports them. The definitions you want to add only return the
> right result in both compilers if you are asking about a builtin that
> clang has and gcc doesn't, which might be your case but doesn't really
> avoid hard-coded compiler checks in all the other cases.
>
Hello,
Well for now I will go for the defined(__has_builtin) && __has_builtin(...)
idiom it in a public .h, and redefine the macros for .c.
We will see whether they will be commonly adapted someday.
I expect my code to be compiled by an ISO C11 compiler or GCC/Clang,
with a fall-back to pseudo-implementation for other compilers (like PCC).
Regards,
Home |
Main Index |
Thread Index |
Old Index