How to check POSIX compatibility?

I am writing a C program with the POSIX API and am using Linux. I compiled and ran it on another Mac OSX PC, and a small error occurred, but I did not use specific Linux features.

I will use some specific features that Linux adds to the API. I will also use special POSIX extensions for Mac OS X and FreeBSD.
I will use conditional compilation to select the code. If the OS is not one, I will use the generic POSIX code.

I do not own Darwin / Mac OSX and FreeBSD, Linux is the only OS that I have on my PC. I cannot download and install FreeBSD because it is over 500 MB.
I want to know how to check if a program will compile and behave as expected on other POSIX systems.
I wonder if there is a POSIX simulator and a compiler for testing.
The tests are simple, they do not use the graphical interface and drivers, they are just a command line.

I will need to do 3 tests: FreeBSD, Mac OSX / Darwin and Generic POSIX, but I have no tools.

EDIT

Is there a minimal version of FreeBSD and Darwin without a GUI, but with GCC / g ++ and ssh / scp? Darwin is free, right? My computer is outdated, but I think I can install them in a virtual machine, create a virtual network and use ssh / scp to transfer and test programs.

+3
source share
2 answers

, . , _POSIX_C_SOURCE POSIX ( 200809L), , , , / POSIX. CFLAGS -D_POSIX_C_SOURCE=200809L. XSI ( Single Unix Standard, POSIX), -D_XOPEN_SOURCE=700.

, , POSIX (, OSX sem_init , , POSIX), , POSIX- (, GNU , regcomp), , .

+5

, , -.

+1

All Articles