Why is #ifdef UNIX not possible in manjaro?

(When programming in c)
It works on Ubuntu so why not on manjaro?

You have to provide more information of what are you doing. But I can say that #ifdef works just fine in Manjaro. This is a programming language feature, not an operating system thing, so whatever problem you have is in your code or in your settings (given that you are using a right compiler)

1 Like

That would depend on your previous defs - wouldn’t it?

I am not very knowledgable with C but it would seem you are missing some headers.

If I recall correct Ubuntu includes kernel headers by default but you have to install them specifically on Manjaro and Arch for that matter.

Ok. I now realized that the question is specific about #ifdef UNIX. I’m don’t know about Ubuntu, but gcc compiler seems to have some predefined macros that actually shouldn’t be there (see: https://stackoverflow.com/questions/19210935/why-does-the-c-preprocessor-interpret-the-word-linux-as-the-constant-1). Also in Manjaro.

Words like unix or linux are defined by default in this compiler, but notice that this is not 1989 ANSI C standard compatible and gcc compiler could change it’s behaviour in the future.

PS: I’m unable to find other references to #define UNIX in google, apart from your own question here (:smiley: ) and a programming example that defines itself UNIX

Even worse, it’s compiler specific. For gcc, try gcc -dM -E - < /dev/null, it should list all predefined macros. And as documented, it defines unix, __unix and __unix__, but not UNIX.

1 Like