{"record":{"id":"9cb3e2c1c607e6c9","repo":"Yalantis/uCrop","slug":"save-pandore-unsupported-datatype-for-file-s","errorCode":null,"errorMessage":"save_pandore(): Unsupported datatype for file '%s'.","messagePattern":"save_pandore\\(\\): Unsupported datatype for file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":63259,"sourceCode":"       cimg::fwrite(buffer,size(),nfile); \\\n       delete[] buffer\n\n#define _cimg_save_pandore_case(sy,sz,sv,stype,id) \\\n      if (!saved && (sy?(sy==_height):true) && (sz?(sz==_depth):true) && \\\n          (sv?(sv==_spectrum):true) && !std::strcmp(stype,pixel_type())) { \\\n        unsigned int *iheader = (unsigned int*)(header + 12); \\\n        nbdims = _save_pandore_header_length((*iheader=id),dims,colorspace); \\\n        cimg::fwrite(header,36,nfile); \\\n        if (sizeof(unsigned long)==4) { CImg<ulongT> ndims(5); \\\n          for (int d = 0; d<5; ++d) ndims[d] = (unsigned long)dims[d]; \\\n          cimg::fwrite(ndims._data,nbdims,nfile); } \\\n        else if (sizeof(unsigned int)==4) { CImg<uintT> ndims(5); \\\n          for (int d = 0; d<5; ++d) ndims[d] = (unsigned int)dims[d]; \\\n          cimg::fwrite(ndims._data,nbdims,nfile); } \\\n        else if (sizeof(unsigned short)==4) { CImg<ushortT> ndims(5); \\\n          for (int d = 0; d<5; ++d) ndims[d] = (unsigned short)dims[d]; \\\n          cimg::fwrite(ndims._data,nbdims,nfile); } \\\n        else throw CImgIOException(_cimg_instance \\\n                                   \"save_pandore(): Unsupported datatype for file '%s'.\",\\\n                                   cimg_instance, \\\n                                   filename?filename:\"(FILE*)\"); \\\n        if (id==2 || id==5 || id==8 || id==16 || id==19 || id==22 || id==26 || id==30) { \\\n          __cimg_save_pandore_case(unsigned char); \\\n        } else if (id==3 || id==6 || id==9 || id==17 || id==20 || id==23 || id==27 || id==31) { \\\n          if (sizeof(unsigned long)==4) { __cimg_save_pandore_case(unsigned long); } \\\n          else if (sizeof(unsigned int)==4) { __cimg_save_pandore_case(unsigned int); } \\\n          else if (sizeof(unsigned short)==4) { __cimg_save_pandore_case(unsigned short); } \\\n          else throw CImgIOException(_cimg_instance \\\n                                     \"save_pandore(): Unsupported datatype for file '%s'.\",\\\n                                     cimg_instance, \\\n                                     filename?filename:\"(FILE*)\"); \\\n        } else if (id==4 || id==7 || id==10 || id==18 || id==21 || id==25 || id==29 || id==33) { \\\n          if (sizeof(double)==4) { __cimg_save_pandore_case(double); } \\\n          else if (sizeof(float)==4) { __cimg_save_pandore_case(float); } \\\n          else throw CImgIOException(_cimg_instance \\\n                                     \"save_pandore(): Unsupported datatype for file '%s'.\",\\","sourceCodeStart":63241,"sourceCodeEnd":63277,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L63241-L63277","documentation":"save_pandore() dispatches dimension-count writing through a macro that stores the dims array using whichever 4-byte unsigned type the platform provides (unsigned int, then unsigned short as fallback). The 'Unsupported datatype' thrown here fires when the platform has no 4-byte unsigned integer type at all — an essentially impossible configuration on modern machines, meaning this specific instance indicates an exotic platform/ABI or a misconfigured cross-build. The message names the target file (or '(FILE*)' when streaming).","triggerScenarios":"Saving a PANDORE file (id in the set selecting the dims-writing branch) on a platform where sizeof(unsigned int)!=4 and sizeof(unsigned short)!=4 — e.g. unusual DSP/embedded targets where unsigned short is 2 bytes and unsigned int is 8.","commonSituations":"Cross-compiling CImg for embedded/DSP toolchains with non-ILP32/LLP64 type widths; exotic ABIs where int is not 32-bit; static analysis flags rather than real user hits on mainstream platforms.","solutions":["Target a platform/ABI where unsigned int is 4 bytes (ILP32, LP64, LLP64) — virtually all mainstream compilers.","Fix the cross-compilation flags/toolchain so the standard 32-bit int model is used.","Patch the CImg macro to add a fallback case (e.g. uint32_t via <cstdint>) for the offending platform.","Verify sizeof(unsigned int) and sizeof(unsigned short) at configure time and fail the build early if neither is 4."],"exampleFix":"// before\n// exotic target: sizeof(unsigned int)==8, sizeof(unsigned short)==2\nimg.save_pandore(\"out.pan\"); // throws on dims write\n\n// after\n#include <cstdint>\nstatic_assert(sizeof(std::uint32_t)==4, \"PANDORE writer needs 32-bit uint\");\nimg.save_pandore(\"out.pan\");","handlingStrategy":"validation","validationCode":"#include <cstdint>\n#if !(UINT_MAX == 4294967295u || USHRT_MAX == 65535u) /* placeholder */\n// simpler:\nstatic_assert(sizeof(unsigned int)==4 || sizeof(unsigned short)==4,\n              \"PANDORE writer requires a 4-byte unsigned type\");","typeGuard":"constexpr bool pandore_dims_ok =\n  sizeof(unsigned int)==4 || sizeof(unsigned short)==4;","tryCatchPattern":"try {\n  img.save_pandore(\"out.pan\");\n} catch (const CImgIOException& e) {\n  std::fprintf(stderr, \"PANDORE unsupported on this platform ABI: %s\\n\", e.what());\n}","preventionTips":["static_assert type widths at build time for cross-compiled targets","Avoid nonstandard -fshort-enums / int-width-changing flags","Test savers on each embedded target ABI you ship"],"tags":["cimg","pandore","platform","datatype"],"backgroundTag":"unsupported-platform","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}