@@ -276,21 +276,29 @@ static fpos_t android_seek(void *cookie, fpos_t offset, int whence);
276276static int android_close (void * cookie );
277277
278278// WARNING: fopen() calls are intercepted via linker flag -Wl,--wrap=fopen: the linker renames
279- // the original fopen -> __real_fopen and redirects all call sites to __wrap_fopen
280- // The flag MUST be applied at every final link step that needs wrapping,
281- // it has no effect when only building a static archive (.a)
279+ // the original fopen -> __real_fopen and redirects all call sites to __wrap_fopen.
280+ // The flag MUST be applied at every final link step that needs wrapping;
281+ // it has no effect when only building a static archive (.a).
282282//
283- // CMake: no action required, raylib's CMakeLists.txt already sets
284- // target_link_options(raylib INTERFACE -Wl,--wrap=fopen) which propagates to
285- // the final app link, wrapping app code and all static (.a) dependencies too
286- // Make (SHARED): no action required for raylib itself, src/Makefile already sets
287- // LDFLAGS += -Wl,--wrap=fopen wrapping fopen inside libraylib.so only;
288- // app code and static (.a) dependencies are NOT wrapped unless -Wl,--wrap=fopen
289- // is also added to the final app link step
290- // Make (STATIC): pass -Wl,--wrap=fopen to the linker command producing the final artifact
291- // build.zig: no dedicated wrap helper; pass -Wl,--wrap=fopen to the linker command producing
292- // the final artifact
293- // custom: pass -Wl,--wrap=fopen to the linker command producing the final artifact
283+ // STATIC library (.a) — wrapping deferred to consumer's final link step:
284+ // both raylib and consumer fopen calls are wrapped together in one link
285+ // CMake: handled automatically — the PUBLIC flag propagates as INTERFACE_LINK_OPTIONS
286+ // to the consumer's final link via target_link_libraries
287+ // Make: pass -Wl,--wrap=fopen to the linker command producing the final artifact
288+ // build.zig: pass -Wl,--wrap=fopen to the linker command producing the final artifact
289+ // custom: pass -Wl,--wrap=fopen to the linker command producing the final artifact
290+ //
291+ // SHARED library (.so) — wrapping is self-contained:
292+ // only fopen calls linked into the .so are wrapped; the consumer's own fopen calls
293+ // are NOT wrapped unless the consumer also links with -Wl,--wrap=fopen independently
294+ // CMake: handled automatically — CMakeLists.txt sets target_link_options(raylib PUBLIC
295+ // -Wl,--wrap=fopen) which applies the flag to the .so link;
296+ // only raylib internals are wrapped, app code requires a separate flag
297+ // Make: handled automatically — src/Makefile sets LDFLAGS += -Wl,--wrap=fopen;
298+ // only raylib internals are wrapped, app code requires a separate flag
299+ // build.zig: NOT supported — std.Build has no dedicated linker wrap helper, the flag
300+ // is not correctly applied at the .so link step
301+ // custom: apply -Wl,--wrap=fopen to the linker command producing the .so
294302FILE * __real_fopen (const char * fileName , const char * mode ); // Real fopen, provided by the linker (--wrap=fopen)
295303FILE * __wrap_fopen (const char * fileName , const char * mode ); // Replacement for fopen()
296304
@@ -1542,7 +1550,7 @@ static void SetupFramebuffer(int width, int height)
15421550
15431551// Replacement for fopen(), used as linker wrap entry point (-Wl,--wrap=fopen)
15441552// REF: https://developer.android.com/ndk/reference/group/asset
1545- FILE * __wrap_fopen (const char * fileName , const char * mode )
1553+ __attribute__(( visibility ( "default" ))) FILE * __wrap_fopen (const char * fileName , const char * mode )
15461554{
15471555 FILE * file = NULL ;
15481556
0 commit comments