added input charset for gcc. not found on linux vm before
fixed macro names
added include of errno.h