Skip to content

Conversation

@bkuhls
Copy link

@bkuhls bkuhls commented Nov 15, 2025

No description provided.

Fixes build error seen with gcc 14.3.0:

ptp2/chdk.c: In function 'yuv_live_to_jpeg':
ptp2/chdk.c:1182:41: error: passing argument 3 of 'jpeg_mem_dest' from incompatible pointer type [-Wincompatible-pointer-types]
 1182 |         jpeg_mem_dest (&cinfo, &outbuf, &outlen);
      |                                         ^~~~~~~
      |                                         |
      |                                         long unsigned int *
In file included from ptp2/chdk.c:32:
/home/autobuild/autobuild/instance-4/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/jpeglib.h:979:28: note: expected 'size_t *' {aka 'unsigned int *'} but argument is of type 'long unsigned int *'
  979 | EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
…_decompress.c

Seen with gcc 14.3.0:

jl2005c/jl2005bcd_decompress.c: In function 'jl2005bcd_decompress':
jl2005c/jl2005bcd_decompress.c:161:46: error: passing argument 3 of 'jpeg_mem_dest' from incompatible pointer type [-Wincompatible-pointer-types]
  161 |         jpeg_mem_dest (&cinfo, &jpeg_header, &jpeg_header_size);
      |                                              ^~~~~~~~~~~~~~~~~
      |                                              |
      |                                              long unsigned int *
In file included from jl2005c/jpeg_memsrcdest.h:4,
                 from jl2005c/jl2005bcd_decompress.c:39:
/home/autobuild/autobuild/instance-4/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/jpeglib.h:979:28: note: expected 'size_t *' {aka 'unsigned int *'} but argument is of type 'long unsigned int *'
  979 | EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
@edgar-bonet
Copy link

edgar-bonet commented Nov 16, 2025

The compilation error @bkuhls is referring to happened on the Buildroot auto-builders, while compiling for Linux with uClibc for mips64el:

jl2005c/jl2005bcd_decompress.c:161:46: error: passing argument 3 of 'jpeg_mem_dest' from incompatible pointer type [-Wincompatible-pointer-types]
  161 |         jpeg_mem_dest (&cinfo, &jpeg_header, &jpeg_header_size);
      |                                              ^~~~~~~~~~~~~~~~~
      |                                              |
      |                                              long unsigned int *
In file included from jl2005c/jpeg_memsrcdest.h:4,
                 from jl2005c/jl2005bcd_decompress.c:39:
…/sysroot/usr/include/jpeglib.h:979:28: note: expected 'size_t *' {aka 'unsigned int *'} but argument is of type 'long unsigned int *'
  979 | EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
      |                            ^~~

As shown by this error message, the variable jpeg_header_size is being passed (by address) as the last argument of jpeg_mem_dest(), thus its type should match the type expected by that function, which here is size_t (aka unsigned int).

This pull request presumably fixes the issue on Linux/mips64el. However, it breaks the build with GCC 14 on Linux/x86_64:

jl2005c/jl2005bcd_decompress.c: In function 'jl2005bcd_decompress':
jl2005c/jl2005bcd_decompress.c:161:46: error: passing argument 3 of 'jpeg_mem_dest' from incompatible pointer type [-Wincompatible-pointer-types]
  161 |         jpeg_mem_dest (&cinfo, &jpeg_header, &jpeg_header_size);
      |                                              ^~~~~~~~~~~~~~~~~
      |                                              |
      |                                              uint32_t * {aka unsigned int *}
In file included from jl2005c/jpeg_memsrcdest.h:4,
                 from jl2005c/jl2005bcd_decompress.c:39:
/usr/include/jpeglib.h:979:28: note: expected 'size_t *' {aka 'long unsigned int *'} but argument is of type 'uint32_t *' {aka 'unsigned int *'}

In order to build on every platform, the type of the variable should be exactly what is written in the prototype of jpeg_mem_dest(), and not some platform-dependent synonym. Now, the problem is this type depends on which implementation of jpeg_mem_dest() is being used:

  • libjpeg 9 expects, as seen here, size_t
  • libjpeg 8 and jpeg-turbo expect unsigned long
  • libjpeg <8 does not provide this function. In this case libgphoto2 uses its own implementation, which expects unsigned long.

A general solution would probably require conditional compilation, maybe checking both JPEG_LIB_VERSION and LIBJPEG_TURBO_VERSION.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants