I am writing my own library for using with my Arduino. In my code, if I set a pointer I have declared to NULL
, such as
int *ptr=NULL;
I get the error
error: ‘NULL’ was not declared in this scope
I need to initialize it to NULL
as I am using pointers to implement a list.
If I use NULL
directly in the program in the IDE, I do not get this error. This seems to be happening only when it is a part of the library code.
How do I correct this? Is there any alternative keyword to use? Or do I have to include some library?
Thank you.
stddef.h
, but that gets included by default anyway, and is used by many other headers, likestdio.h
. – Majenko♦ Feb 8 '17 at 14:40NULL
in a definition of a header file which I have written. I hadn't realized that it works otherwise. Edited by question. – GoodDeeds Feb 8 '17 at 14:46