Yalantis/uCrop · error · CImgIOException
cimg::stdout(): Reference to 'stdout' stream not allowed in…
Error message
cimg::stdout(): Reference to 'stdout' stream not allowed in R mode ('cimg_use_r' is defined). What it means
cimg::stdout() in an R-mode build (cimg_use_r defined) refuses to return the raw stdout FILE*, because writing to it bypasses R's output plumbing and can garble or crash the R session. With throw_exception true, it throws CImgIOException.
Solutions
- Use Rprintf/Rconsolemsg (R API) for output instead of cimg::stdout() in R-mode builds.
- Disable verbose CImg output (cimg::verbosity(0)) so code paths never request stdout.
- Build without cimg_use_r if direct stdio access is required.
- Catch CImgIOException and redirect output through R's supported channels.
Example fix
// before
std::FILE* out = cimg::stdout(); // throws in R mode
// after
#ifdef cimg_use_r
Rprintf("%s", msg.c_str());
#else
std::fprintf(cimg::stdout(), "%s", msg.c_str());
#endif Defensive patterns
Strategy: try-catch
Validate before calling
bool stdoutAllowed() {
#ifndef cimg_use_r
return true;
#else
return false;
#endif
} Type guard
bool stdioAvailable() { return
#ifndef cimg_use_r
true;
#else
false;
#endif
} Try / catch
try {
std::FILE* out = cimg::stdout();
} catch (CImgIOException& e) {
// R mode: print via Rprintf instead
} Prevention
- Route all logging through an abstraction that picks Rprintf vs stdio at compile time.
- Disable CImg verbosity in R-mode builds.
- Guard direct stdio usage with preprocessor checks.
When it happens
Trigger: Calling cimg::stdout() (directly or via CImg features that print, verbose logging, or progress output) in a build compiled with cimg_use_r.
Common situations: Porting standalone CImg applications into an R package; enabling verbose/debug CImg output inside R sessions; code that caches cimg::stdout() at module init.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- cimg::stderr(): Reference to 'stderr' stream not allowed in…
- cimg::stdin(): Reference to 'stdin' stream not allowed in R…
- CImgList< >::get_unserialize(): Unable to unserialize…
- CImgDisplay(): No display available.
- CImgList< >::get_unserialize(): CImg header not found in…
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/125927324ad33c7f.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:69119
return stdin;
#else
if (throw_exception) {
cimg::exception_mode(0);
throw CImgIOException("cimg::stdin(): Reference to 'stdin' stream not allowed in R mode "
"('cimg_use_r' is defined).");
}
return 0;
#endif
}
inline FILE* _stdout(const bool throw_exception) {
#ifndef cimg_use_r
cimg::unused(throw_exception);
return stdout;
#else
if (throw_exception) {
cimg::exception_mode(0);
throw CImgIOException("cimg::stdout(): Reference to 'stdout' stream not allowed in R mode "
"('cimg_use_r' is defined).");
}
return 0;
#endif
}
inline FILE* _stderr(const bool throw_exception) {
#ifndef cimg_use_r
cimg::unused(throw_exception);
return stderr;
#else
if (throw_exception) {
cimg::exception_mode(0);
throw CImgIOException("cimg::stderr(): Reference to 'stderr' stream not allowed in R mode "
"('cimg_use_r' is defined).");
}
return 0;
#endifView on GitHub (pinned to f788b534b4)