[PATCH 1/2] Fix compilation with older libzip
Dirk Hohndel
dirk at hohndel.org
Thu Dec 5 19:10:12 UTC 2013
Close but no cigar:
Close but no cigar:
compiling qt-ui/subsurfacewebservices.cpp
qt-ui/subsurfacewebservices.cpp: In member function 'void DivelogsDeWebServices::downloadFinished()':
qt-ui/subsurfacewebservices.cpp:630:46: error: call of overloaded 'zip_get_num_entries(zip*&, int)' is ambiguous
quint64 entries = zip_get_num_entries(zip, 0);
^
qt-ui/subsurfacewebservices.cpp:630:46: note: candidates are:
In file included from qt-ui/subsurfacewebservices.cpp:6:0:
/usr/i686-w64-mingw32/sys-root/mingw/include/zip.h:267:24: note: zip_int64_t zip_get_num_entries(zip*, zip_flags_t)
ZIP_EXTERN zip_int64_t zip_get_num_entries(struct zip *, zip_flags_t);
^
qt-ui/subsurfacewebservices.cpp:31:12: note: int zip_get_num_entries(zip*, qint64)
static int zip_get_num_entries(struct zip *z, qint64)
(cross compiling for Windows under Fedora 19)
This seems to work:
- quint64 entries = zip_get_num_entries(zip, 0);
+ quint64 entries = zip_get_num_entries(zip, (zip_flags_t)0);
/D
On Thu, 2013-12-05 at 15:34 -0800, Thiago Macieira wrote:
Older libzip lack zip_get_num_entries. Explanation for the hack is in
> the comment.
>
> Signed-off-by: Thiago Macieira <thiago at macieira.org>
> ---
> qt-ui/subsurfacewebservices.cpp | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
> index 8dd6b59..6e041d6 100644
> --- a/qt-ui/subsurfacewebservices.cpp
> +++ b/qt-ui/subsurfacewebservices.cpp
> @@ -23,6 +23,16 @@
> # include <unistd.h> // for dup(2)
> #endif
>
> +/* older versions of libzip don't have zip_get_num_entries;
> + * unfortunately, zip.h doesn't come with a version macro for us, so
> + * hack around it by providing an overload in that has a lower search
> + * precendence: the second argument here is a 64-bit int, but we make
> + * call below with a literal 0, which binds better to an int */
> +static int zip_get_num_entries(struct zip *z, qint64)
> +{
> + return zip_get_num_files(z);
> +}
> +
> struct dive_table gps_location_table;
> static bool merge_locations_into_dives(void);
>
>
On Thu, 2013-12-05 at 15:34 -0800, Thiago Macieira wrote:
> Older libzip lack zip_get_num_entries. Explanation for the hack is in
> the comment.
>
> Signed-off-by: Thiago Macieira <thiago at macieira.org>
> ---
> qt-ui/subsurfacewebservices.cpp | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
> index 8dd6b59..6e041d6 100644
> --- a/qt-ui/subsurfacewebservices.cpp
> +++ b/qt-ui/subsurfacewebservices.cpp
> @@ -23,6 +23,16 @@
> # include <unistd.h> // for dup(2)
> #endif
>
> +/* older versions of libzip don't have zip_get_num_entries;
> + * unfortunately, zip.h doesn't come with a version macro for us, so
> + * hack around it by providing an overload in that has a lower search
> + * precendence: the second argument here is a 64-bit int, but we make
> + * call below with a literal 0, which binds better to an int */
> +static int zip_get_num_entries(struct zip *z, qint64)
> +{
> + return zip_get_num_files(z);
> +}
> +
> struct dive_table gps_location_table;
> static bool merge_locations_into_dives(void);
>
More information about the subsurface
mailing list