|
|
| 'NULL' undeclared... |
|
Denis Sinner
Member #4,278
January 2004
|
I Wrote a class which includes an pointer to the next Object of the same class. It worked fine. Then i tried to place the class in it's own header h. + .cpp file. Now when i'm trying to compile, i'm getting the following error:(I'm Using Dev cpp) `NULL' undeclared (first use this function) (I'm using NULL in the constructor for the pointer to the next Object) |
|
Chris Katko
Member #1,881
January 2002
|
Include a standard header perhaps? -----sig: |
|
Korval
Member #1,538
September 2001
|
I would venture the following guess. One of the .cpp files that includes the .h file includes it before including anything else (like <stdlib.h> and so forth). You should include your standard library headers first. |
|
Radagar
Member #2,768
September 2002
|
I know this makes a difference with Visual Studio, but I'm not sure about DevCpp. Try renaming the .h file to .hpp NULL is not declared in C, but is in C++, if I remember correctly. ------------ |
|
Zaphos
Member #1,468
August 2001
|
You could just do: #ifndef NULL #define NULL 0 #endif Radagar: NULL is declared in standard header files. I'm not sure why .h -> .hpp would do anything at all ... it sounds silly.
|
|
Billybob
Member #3,136
January 2003
|
I'm wondering why no one ranted yet... [url http://www.allegro.cc/forums/view_thread.php?_id=331783]
|
|
23yrold3yrold
Member #1,134
March 2001
|
Yeah, I was about to link that -- |
|
Chris Katko
Member #1,881
January 2002
|
Quote: Radagar: NULL is declared in standard header files. I'm not sure why .h -> .hpp would do anything at all ... it sounds silly. He didn't include any standard header files first off, secondly there's a difference between c and cpp files. And ofcourse, read the link. -----sig: |
|
Zaphos
Member #1,468
August 2001
|
Quote: He didn't include any standard header files first off, secondly there's a difference between c and cpp files. I know both these things, I've read the link (before reading this thread, actually), and your post has no relevance whatsoever to what you quoted.
|
|
Chris Katko
Member #1,881
January 2002
|
The "And ofcourse, read the link." part was for the OP. -----sig: |
|
Surt
Member #273
April 2000
|
NULL is declared in <stddef.h> under C and <cstddef> under C++. --- |
|
|