Search code examples
nullaixxlc

What is the meaning of comparing char to NULL on AIX (xlc)?


I am porting AIX code to Linux. I encountered some code which compares char to NULL on AIX xlc compiler. The same code gives compile error on Linux.

There is code which compares double with NULL ( d != NULL).

Could somebody explain the semantics of comparing char or double to NULL on AIX(xlc).


Solution

  • With xlc on AIX, "NULL" is a macro for "0" instead of "(void *)0" so the comparison after the preprocessor runs is valid for char/int/double.

    You can see this with xlc -E or gcc -E on your code.

    Never use this for anything -- it's just trivia. Fix your code to not use NULL in non-pointer context.