Version | Standard | Release Year |
---|---|---|
POSIX.1 | IEEE Std 1003.1-1988 | 1988-01-01 |
POSIX.1b | IEEE Std 1003.1b-1993 | 1993-01-01 |
POSIX.1c | IEEE Std 1003.1c-1995 | 1995-01-01 |
POSIX.2 | IEEE Std 1003.2-1992 | 1992-01-01 |
POSIX.1-2001 | IEEE Std 1003.1-2001 | 2001-12-06 |
POSIX.1-2004 | IEEE Std 1003.1-2004 | 2004-01-01 |
POSIX.1-2008 | IEEE Std 1003.1-2008 (aka "Base Specifications, Issue 7") | 2008-12-01 |
POSIX.1-2013 | IEEE Std 1003.1-2013 | 2013-04-19 |
POSIX.1-2016 | IEEE Std 1003.1-2016 | 2016-09-30 |
POSIX stands for "Portable Operating System Interface" and defines a set of standards to provide compatibility between different computing platforms. The current version of the standard is IEEE 1003.1 2016 and can be accessed from the OpenGroup POSIX specification. Previous versions include POSIX 2004 and POSIX 1997. The POSIX 2016 edition is essentially POSIX 2008 plus errata (there was a POSIX 2013 release too).
POSIX defines various tools interfaces, commands and APIs for UNIX-like operating systems and others.
The following are considered to be within the scope of POSIX standardization:
Outside of POSIX scope:
A simple Hello, World
program without error checking:
#include <unistd.h> /* For write() and STDOUT_FILENO */
#include <stdlib.h> /* For EXIT_SUCCESS and EXIT_FAILURE */
int main(void) {
char hello[] = "Hello, World\n";
/* Attempt to write `hello` to standard output file */
write(STDOUT_FILENO, hello, sizeof(hello) - 1);
return EXIT_SUCCESS;
}
And with error checking:
#include <unistd.h> /* For write() and STDOUT_FILENO */
#include <stdlib.h> /* For EXIT_SUCCESS and EXIT_FAILURE */
int main(void) {
char hello[] = "Hello, World\n";
ssize_t ret = 0;
/* Attempt to write `hello` to standard output file */
ret = write(STDOUT_FILENO, hello, sizeof(hello) - 1);
if (ret == -1) {
/* write() failed. */
return EXIT_FAILURE;
} else if (ret != sizeof(hello) - 1) {
/* Not all bytes of `hello` were written. */
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
If the code shown above (either version) is stored in file hello.c
, then you can compile the code into a program hello
using either c99
or
make
. For example, in a strictly POSIX compliant mode, you might in theory compile and run the program using:
$ make hello
c99 -o hello hello.c
$ ./hello
Hello, World
$
Most actual make
implementations will use a different C compiler (perhaps cc
, perhaps gcc
, clang
, xlc
or some other name), and many will use more options to the compiler. Clearly, you could simply type the command that make
executes directly on the command line.