[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to test for a prototype difference
From: |
Nick Bowler |
Subject: |
Re: how to test for a prototype difference |
Date: |
Fri, 16 May 2014 11:19:58 -0400 |
User-agent: |
Mutt/1.5.22 (2013-10-16) |
Hello,
Some comments...
On 2014-05-16 02:33 +0200, Thomas Klausner wrote:
> Hi Eric!
>
> On Wed, Apr 30, 2014 at 06:51:23PM -0600, Eric Blake wrote:
> > On 04/30/2014 06:12 PM, Thomas Klausner wrote:
[...]
> > > I'd like to test for the difference int <-> size_t in a configure
> > > script so I can get integer type/sign conversion-warnings free code on
> > > all these operating systems.
> > >
> > > I'm however not sure how to do this. Does anyone have a suggestion?
[...]
> Here's what I came up with:
> AC_CACHE_CHECK([parameter type for backtrace()],
> [am_cv_proto_backtrace_type],
The am_cv_ prefix is used by Automake so I suggest choosing a
different one.
> [AC_COMPILE_IFELSE(
> [AC_LANG_PROGRAM(
> [[
> #include <execinfo.h>
> extern
> #ifdef __cplusplus
> "C"
> #endif
> size_t backtrace(void **addrlist, size_t len);
> ]])
> ],
> [am_cv_proto_backtrace_type=size_t],
> [am_cv_proto_backtrace_type=int])
So if the compilation fails for any reason, you set the type to int.
That could be OK in your case (depending how you use it) but it seems
a little weird to me.
> ])
> AC_DEFINE_UNQUOTED([backtrace_t], [$am_cv_proto_backtrace_type],
> [Define to return type for backtrace().])
Note that POSIX reserves identifiers ending in _t if you include any
header file, so you should normally avoid using that suffix in an
application.
Cheers,
--
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)