From 440adddcde73ff60c947f5c48de342c063f6aa3f Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Thu, 1 Dec 2011 10:50:14 +0000 Subject: [PATCH] [trunk] fix warnings when printing large integers --- CHANGES | 1 + applications/codec/index.c | 2 +- libopenjpeg/j2k.c | 9 +++++---- libopenjpeg/openjpeg.h | 16 +++++++++++++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index d8e93471..6ca91d31 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ What's New for OpenJPEG December 1, 2011 * [mickael] fix a warning about a recent commit (1104) +* [jmalik] fix warnings when printing large integers November 30, 2011 * [jmalik] implement Large File support in the library : diff --git a/applications/codec/index.c b/applications/codec/index.c index d500ce5e..b53d0417 100644 --- a/applications/codec/index.c +++ b/applications/codec/index.c @@ -383,7 +383,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) { fprintf(stream, "%d\n", cstr_info->marknum); fprintf(stream, "type\tstart_pos length\n"); for (x = 0; x < cstr_info->marknum; x++) - fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len); + fprintf(stream, "%X\t%9" OPJ_OFF_F "d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len); } /* <main_head_start, cstr_index->main_head_end); fprintf(out_stream, "\t Marker list: {\n"); if (cstr_index->marker){ for (it_marker=0; it_marker < cstr_index->marknum ; it_marker++){ - fprintf(out_stream, "\t\t type=%#x, pos=%d, len=%d\n", + fprintf(out_stream, "\t\t type=%#x, pos=%" OPJ_OFF_F "d, len=%d\n", cstr_index->marker[it_marker].type, cstr_index->marker[it_marker].pos, cstr_index->marker[it_marker].len ); @@ -7762,7 +7763,7 @@ void j2k_dump_MH_index(opj_j2k_v2_t* p_j2k, FILE* out_stream) if (cstr_index->tile_index[it_tile].tp_index){ for (it_tile_part =0; it_tile_part < nb_of_tile_part; it_tile_part++){ - fprintf(out_stream, "\t\t\t tile-part[%d]: star_pos=%d, end_header=%d, end_pos=%d.\n", + fprintf(out_stream, "\t\t\t tile-part[%d]: star_pos=%" OPJ_OFF_F "d, end_header=%" OPJ_OFF_F "d, end_pos=%" OPJ_OFF_F "d.\n", it_tile_part, cstr_index->tile_index[it_tile].tp_index[it_tile_part].start_pos, cstr_index->tile_index[it_tile].tp_index[it_tile_part].end_header, @@ -7772,7 +7773,7 @@ void j2k_dump_MH_index(opj_j2k_v2_t* p_j2k, FILE* out_stream) if (cstr_index->tile_index[it_tile].marker){ for (it_marker=0; it_marker < cstr_index->tile_index[it_tile].marknum ; it_marker++){ - fprintf(out_stream, "\t\t type=%#x, pos=%d, len=%d\n", + fprintf(out_stream, "\t\t type=%#x, pos=%" OPJ_OFF_F "d, len=%d\n", cstr_index->tile_index[it_tile].marker[it_marker].type, cstr_index->tile_index[it_tile].marker[it_marker].pos, cstr_index->tile_index[it_tile].marker[it_marker].len ); diff --git a/libopenjpeg/openjpeg.h b/libopenjpeg/openjpeg.h index d8a332b3..90de1d27 100644 --- a/libopenjpeg/openjpeg.h +++ b/libopenjpeg/openjpeg.h @@ -76,7 +76,7 @@ typedef int opj_bool; /*FIXME it should be to follow the name of others OPJ_TYPE #define OPJ_TRUE 1 #define OPJ_FALSE 0 -// FIXME : should be better defined by configure/CMake test +/* FIXME : should be better defined by configure/CMake test */ typedef unsigned int OPJ_UINT32; typedef int OPJ_INT32; typedef unsigned short OPJ_UINT16; @@ -88,17 +88,27 @@ typedef double OPJ_FLOAT64; typedef float OPJ_FLOAT32; #if (defined(WIN32) || defined(WIN64)) && !defined(__MINGW32__) + typedef signed __int64 OPJ_INT64; +#define OPJ_INT64_F "I64" typedef unsigned __int64 OPJ_UINT64; +#define OPJ_UINT64_F "I64" + #else + typedef long long OPJ_INT64; +#define OPJ_INT64_F "ll" + typedef unsigned long long OPJ_UINT64; +#define OPJ_UINT64_F "ll" + #endif -/* 64-bit file and blob offset type */ +/* 64-bit file offset type */ typedef OPJ_INT64 OPJ_OFF_T; +#define OPJ_OFF_F OPJ_INT64_F -// Avoid compile-time warning because parameter is not used +/* Avoid compile-time warning because parameter is not used */ #define OPJ_ARG_NOT_USED(x) (void)(x) /*