From: malaterre Date: Fri, 4 Feb 2005 23:30:21 +0000 (+0000) Subject: BUG: Fix compilation warning on SunOS-CC: Warning (Anachronism): Assigning void(... X-Git-Tag: Version1.0.bp~86 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e91342d20e4553e4479c23a300f98c8dff3424aa;p=gdcm.git BUG: Fix compilation warning on SunOS-CC: Warning (Anachronism): Assigning void(*)(jpeg_decompress_struct*,long) to extern C void(*)(jpeg_decompress_struct*,long). This is not safe to pass a function pointer from a C context to a C++ context. Explicitely reinterpret_cast it. --- diff --git a/src/gdcmJpeg.cxx b/src/gdcmJpeg.cxx index 762de9d4..5a2fb984 100644 --- a/src/gdcmJpeg.cxx +++ b/src/gdcmJpeg.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJpeg.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 10:02:18 $ - Version: $Revision: 1.40 $ + Date: $Date: 2005/02/04 23:30:21 $ + Version: $Revision: 1.41 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -173,6 +173,9 @@ bool gdcm_write_JPEG_file (std::ofstream *fp, void *im_buf, return true; //??? } +extern "C" { + typedef void(*void_jpeg_common_struct)(jpeg_common_struct*); +} //----------------------------------------------------------------------------- struct my_error_mgr { @@ -243,7 +246,7 @@ bool JPEGFragment::ReadJPEGFile (std::ifstream *fp, void *image_buffer, int &sta // We set up the normal JPEG error routines, then override error_exit. cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = my_error_exit; + jerr.pub.error_exit = reinterpret_cast(my_error_exit); // Establish the setjmp return context for my_error_exit to use. if (setjmp(jerr.setjmp_buffer)) diff --git a/src/jdatadst.cxx b/src/jdatadst.cxx index 3b850570..b0776553 100644 --- a/src/jdatadst.cxx +++ b/src/jdatadst.cxx @@ -19,6 +19,11 @@ /* Expanded data destination object for stdio output */ +extern "C" { + typedef int(*int_jpeg_compress_struct)(jpeg_compress_struct*); + typedef void(*void_jpeg_compress_struct)(jpeg_compress_struct*); +} + typedef struct { struct jpeg_destination_mgr pub; /* public fields */ @@ -159,8 +164,8 @@ jpeg_stdio_dest (j_compress_ptr cinfo, std::ofstream * outfile) } dest = (my_dest_ptr) cinfo->dest; - dest->pub.init_destination = init_destination; - dest->pub.empty_output_buffer = empty_output_buffer; - dest->pub.term_destination = term_destination; + dest->pub.init_destination = reinterpret_cast(init_destination); + dest->pub.empty_output_buffer = reinterpret_cast(empty_output_buffer); + dest->pub.term_destination = reinterpret_cast(term_destination); dest->outfile = outfile; } diff --git a/src/jdatasrc.cxx b/src/jdatasrc.cxx index c0fb1220..a7c0a368 100644 --- a/src/jdatasrc.cxx +++ b/src/jdatasrc.cxx @@ -18,6 +18,12 @@ /* Expanded data source object for stdio input */ +extern "C" { + typedef int(*int_jpeg_decompress_struct)(jpeg_decompress_struct*); + typedef void(*void_jpeg_decompress_struct)(jpeg_decompress_struct*); + typedef void(*void_jpeg_decompress_struct_long)(jpeg_decompress_struct*,long); +} + typedef struct { struct jpeg_source_mgr pub; /* public fields */ @@ -214,11 +220,11 @@ jpeg_stdio_src (j_decompress_ptr cinfo, std::ifstream * infile, gdcm::JPEGFragme } src = (my_src_ptr) cinfo->src; - src->pub.init_source = init_source; - src->pub.fill_input_buffer = fill_input_buffer; - src->pub.skip_input_data = skip_input_data; + src->pub.init_source = reinterpret_cast(init_source); + src->pub.fill_input_buffer = reinterpret_cast(fill_input_buffer); + src->pub.skip_input_data = reinterpret_cast(skip_input_data); src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->pub.term_source = term_source; + src->pub.term_source = reinterpret_cast(term_source); src->infile = infile; // Need to setup a new buffer, clean bytes_in_buffer and next_input_byte