Groups | Search | Server Info | Login | Register
Groups > comp.databases.berkeley-db > #8
| From | ImpalerCore <jadill33@gmail.com> |
|---|---|
| Newsgroups | comp.databases.berkeley-db, comp.lang.c |
| Subject | Re: error: conflicting declaration 'typedef int32_t ssize_t' (mingw versus berkeley db) |
| Date | 2011-11-29 13:07 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <1ab8e3c3-8b36-4523-a79f-c5cfb61c82c5@h3g2000yqa.googlegroups.com> (permalink) |
| References | <3e9fb$4ed19745$5419acc3$27249@cache1.tilbu1.nb.home.nl> |
Cross-posted to 2 groups.
On Nov 26, 8:50 pm, "Skybuck Flying" <Windows7I...@DreamPC2006.com>
wrote:
> Hello,
>
> Building the bitcoin-qt 0.5.0rc7 client for win32 (on windows 7) has a
> little problem, qtcreator reports a conflicting type "ssize_t".
>
> So two simple questions I guess:
>
> 1. How many bits should ssize_t be for mingw32 (types.h) ?
> 2. How many bits should ssize_t be for berkeley db (db.h) ?
The number of bits for 'ssize_t' should be the same number of bits of
'size_t'.
> And finally:
>
> 3. What would be a good solution to fix it ? (I could rename the type in
> db.h and modify all source code of berkeley db, but maybe there is an easier
> way ? Also I am not sure if renaming the type would help, since maybe there
> is a size conflict as well, hence questions 1 and 2 to be sure... )
One option would be to rely on the detection of a <sys/types.h> file,
a la autoconf and friends.
\code
#if defined(HAVE_SYS_TYPES_H)
/* Let's MinGW or other native OS define 'ssize_t' for you */
# include <sys/types.h>
#else
... Define ssize_t in your own way ...
#endif
\endcode
where '... Define ssize_t in your own way ...' could be
\code snippet db.h
#ifdef _WIN64
typedef int64_t ssize_t;
#else
typedef int32_t ssize_t;
#endif
\endcode
This would require you to manually define -DHAVE_SYS_TYPES_H in the
configuration if the build environment doesn't support run-time
detection of compiler and library features (like whether you can
include <sys/types.h>).
Ideally, defining a proper 'ssize_t' type should also include an
appropriate limit along the lines of 'SSIZE_MAX'. Another option is
to inspect whether the 'SSIZE_MAX' symbol is defined is use that
information to infer whether 'ssize_t' is defined as well. MinGW
defines one in its <limits.h>. YMMV
You can insert a compile-time assertion to verify that "sizeof
(size_t) == sizeof (ssize_t)" if you want to be sure.
#define C_STATIC_ASSERT(name, expr) extern char (name)[(expr) ? 1 :
-1]
C_STATIC_ASSERT( ssize_t_is_compatible_with_size_t,
sizeof (ssize_t) == sizeof (size_t) );
Best regards,
John D.
Back to comp.databases.berkeley-db | Previous | Next — Previous in thread | Find similar
error: conflicting declaration 'typedef int32_t ssize_t' (mingw versus berkeley db) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2011-11-27 02:50 +0100
Re: error: conflicting declaration 'typedef int32_t ssize_t' (mingw versus berkeley db) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2011-11-27 03:04 +0100
Re: error: conflicting declaration 'typedef int32_t ssize_t' (mingw versus berkeley db) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2011-11-27 03:27 +0100
Re: error: conflicting declaration 'typedef int32_t ssize_t' (mingw versus berkeley db) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2011-11-27 04:01 +0100
Re: error: conflicting declaration 'typedef int32_t ssize_t' (mingw versus berkeley db) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2011-11-27 19:42 +0100
Re: error: conflicting declaration 'typedef int32_t ssize_t' (mingw versus berkeley db) ImpalerCore <jadill33@gmail.com> - 2011-11-29 13:07 -0800
csiph-web