bitbank2 / JPEGDEC

An optimized JPEG decoder for Arduino
Apache License 2.0
366 stars 47 forks source link

Rename jpeg.c to jpeg.cpp for Arduino PlatformIO compilation #11

Closed mrcodetastic closed 3 years ago

mrcodetastic commented 3 years ago

Hi Larry,

Firstly, absolutely amazing library. Thank you for providing this to the public to use. However, I noticed that when using PlatformIO (not Arduino IDE) I cannot compile. This is due to some PlatformIO behaviour with mixed c and cpp files: https://community.platformio.org/t/resolved-fatal-error-memory-no-such-file-or-directory/914

Would it be possible to change the extension to .cpp? It is possible to compile then.

Compiling .pio\build\lolin_d32\libc53\JPEGDEC-master\JPEGDEC.cpp.o
Compiling .pio\build\lolin_d32\libc53\JPEGDEC-master\jpeg.c.o
In file included from lib\JPEGDEC-master\src\JPEGDEC.h:26:0,
                 from lib\JPEGDEC-master\src\jpeg.c:23:
C:\Users\Anonymous\.platformio\packages\framework-arduinoespressif32\libraries\FS\src/FS.h:24:18: fatal error: memory: No such file or directory
compilation terminated.
*** [.pio\build\lolin_d32\libc53\JPEGDEC-master\jpeg.c.o] Error 1
In file included from lib\JPEGDEC-master\src\JPEGDEC.cpp:32:0:
lib\JPEGDEC-master\src\jpeg.c:32:16: warning: 'int32_t readFile(JPEGFILE*, uint8_t*, int32_t)' declared 'static' but never defined [-Wunused-function]
 static int32_t readFile(JPEGFILE *pFile, uint8_t *pBuf, int32_t iLen);
bitbank2 commented 3 years ago

I left it as .c because on some embedded platforms that's the only compiler available and it would get misinterpreted by Arduino if you change the name extension. If you'll notice, it currently gets included into JPEGDEC.cpp so that it will be compiled as C++ code on Arduino. A quick fix for platformio is to rename it to jpeg.h and change the include line in JPEGDEC.cpp. This would make it more confusing for Linux/Embedded builds, so I'm not sure what the right plan is. Can you possibly exclude it from getting built in the project file?