Defining your own NULL value is not standard, and very error prone and that will for sure give you no sleep nights and headaches in the best case.
Issues with the concept of NULL values between C and C++ and within C++ C++98, C++0x, and C++11 is not new, this is why from C++0x onward the nullptr macro has been introduced to avoid issues and harmonise things a bit.
If however you used code that inherits from issue of the legacy NULL burden:
Depending on your configuration, in the order in which your externals and libs are included etc, you might need to ensure that NULL is defined on time.
The easiest way is to include "stddef.h", note that the content of stddef.h may vary a lot depending on your system/linux flavor, this is an example:
#ifndef _LINUX_STDDEF_H
#define _LINUX_STDDEF_H
#undef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
Example:
I had the issue trying to use the i2c library to drive i2c buses on a Raspberry-pi.
In my case including the i2c lib wasn't enough, I had to create a utils.h file that I include in place of the i2c lib header:
#ifndef UTILS_H
#define UTILS_H
/// if you have to use i2c-dev.h then use this utils header instead of make sure to include stddef.h before.
/// otherwise you will end up with the following error:
/// .../arm-unknown-linux-gnueabi/arm-unknown-linux- gnueabi/sysroot/usr/include/linux/i2c-dev.h:175: error: 'NULL' undeclared (first use in this function)
/// return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);
/// ^
#include <stddef.h>
#include <linux/i2c-dev.h>
#endif // UTILS_H