diff --git a/include/prism/defines.h b/include/prism/defines.h index 849ca6d0516..a4246e67c8a 100644 --- a/include/prism/defines.h +++ b/include/prism/defines.h @@ -118,6 +118,15 @@ # endif #endif +/** + * If PRISM_HAS_NO_FILESYSTEM is defined, then we want to exclude all filesystem + * related code from the library. All filesystem related code should be guarded + * by PRISM_HAS_FILESYSTEM. + */ +#ifndef PRISM_HAS_NO_FILESYSTEM +# define PRISM_HAS_FILESYSTEM +#endif + /** * isinf on Windows is defined as accepting a float, but on POSIX systems it * accepts a float, a double, or a long double. We want to mirror this behavior diff --git a/src/util/pm_string.c b/src/util/pm_string.c index 6545bce319f..0a67accd866 100644 --- a/src/util/pm_string.c +++ b/src/util/pm_string.c @@ -202,7 +202,7 @@ pm_string_file_init(pm_string_t *string, const char *filepath) { CloseHandle(file); *string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = (size_t) file_size }; return true; -#else +#elif defined(PRISM_HAS_FILESYSTEM) FILE *file = fopen(filepath, "rb"); if (file == NULL) { return false; @@ -241,6 +241,11 @@ pm_string_file_init(pm_string_t *string, const char *filepath) { *string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = length }; return true; +#else + (void) string; + (void) filepath; + perror("pm_string_file_init is not implemented for this platform"); + return false; #endif }