0

I'm coming from a windows background so I'm a bit new here, but I'm trying to conditionally use mmap() but only if the platform supports it.

I know now it's a POSIX standard, and I'd like to check for it in my code. However, I'm confused as to the best way to do it.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html

Looking here it says this: CHANGE HISTORY First released in Issue 4, Version 2.

I don't know how to translate to an #if check.

I want to check the POSIX version to make sure its defined and at minimum the version in which mmap is supported.

Google doesn't seem to be much help here.

#if ?????
// code to use mmap()
#endif

That's what I want. Just the ???? part

Thanks in advance.

  • 2
    Does this answer your question? [How can I determine if the operating system is POSIX in C?](https://stackoverflow.com/questions/11350878/how-can-i-determine-if-the-operating-system-is-posix-in-c) i.e. `_POSIX_VERSION` should be `#define`d in ``. There is also `_POSIX_C_SOURCE`, to be defined by _you_ in order to ensure symbols for a given version are visible (or, as the case may be, not). – underscore_d Jan 05 '21 at 17:04
  • aha the second answer unistd.h _POSIX_VERSION thanks. I still don't know which version to check for, but at least I have more information than I started with. I appreciate it. – honey the codewitch Jan 05 '21 at 17:06

0 Answers0