CFLAGS = $(INCPATH) -Wall -Werror -Wwrite-strings -Wextra -Wno-unused-parameter -D__AMIGADATE__=\"`c:date LFORMAT %Y-%m-%d`\" -O3 struct JPEGDecHandle *jph; err=IJpeg->AllocJPEGDecompress(&jph, JPG_SrcMemStream, jstream, JPG_SrcMemStreamSize, jstreamsize, TAG_DONE);
I am trying to compile the jpeg_lib.lha (Aminet) library example 'save_file'. I can't get past this error:
warning: passing argument 2 of 'IJpeg->AllocJPEGDecompress' from incompatible pointer type.
It happens for all of these functions:
AllocJPEGDecompress AllocBufferFromJPEG DecompressJPEG AllocJPEGCompress CompressJPEG FreeJPEGCompress FreeJPEGDecompress
I have tried every variation of cast I can think of. Tried -fno-strict-aliasing (like in jabirulo's post). Same thing every time.
Tried the jpeg's loadfile source code and I get the same warning:
even doing "IJpeg->FreeJPEGDecompress( (struct JPEGDecHandle *)jph );" I get the same warning
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
The problem is that the include file "interfaces/jpeg.h" doesn't include "jpeg/jpeg.h", so when gcc first encounters struct JPEGDecHandle in a function definition there it creates an implicit local definition. That's why later when it encounters the JPEGDecHandle in "jpeg/jpeg.h" it thinks it's a different structure.
This is also why you should always check the first warning/error first when compiling C code because it will often explain later ones and when you fix it they will be fixed too.
In this case gcc reported this error:
Fix this either by moving the "#include <jpeg/jpeg.h>" line before "#include <proto/jpeg.h>", or by adding "#include <jpeg/jpeg.h>" just after:
in "interfaces/jpeg.h".
Added "#include <jpeg/jpeg.h>" in interfaces/jpeg.h and no more warnings. THXALOT
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
I was loading the proto first, flipped the order and it compiled. No need to manually add the line to interfaces.
Thank you!