kastnermario / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

error: ‘NULL’ was not declared in this scope in ptr_stack.h and ptr_vector.h #112

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Steps to reproduce:
$ wget 'http://yaml-cpp.googlecode.com/files/yaml-cpp-0.2.6.tar.gz'
$ tar xzf yaml-cpp-0.2.6.tar.gz  
$ cd yaml-cpp 
$ mkdir build
$ cd build
$ cmake -G "Unix Makefiles" ..
$ make

Output:
[  3%] Building CXX object CMakeFiles/yaml-cpp.dir/src/tag.cpp.o
[  6%] Building CXX object CMakeFiles/yaml-cpp.dir/src/ostream.cpp.o
[  9%] Building CXX object CMakeFiles/yaml-cpp.dir/src/stream.cpp.o
[ 12%] Building CXX object CMakeFiles/yaml-cpp.dir/src/parser.cpp.o
[ 15%] Building CXX object CMakeFiles/yaml-cpp.dir/src/conversion.cpp.o
[ 18%] Building CXX object CMakeFiles/yaml-cpp.dir/src/singledocparser.cpp.o
[ 21%] Building CXX object CMakeFiles/yaml-cpp.dir/src/emitterutils.cpp.o
[ 25%] Building CXX object CMakeFiles/yaml-cpp.dir/src/scantag.cpp.o
[ 28%] Building CXX object CMakeFiles/yaml-cpp.dir/src/emitter.cpp.o
[ 31%] Building CXX object CMakeFiles/yaml-cpp.dir/src/emitterstate.cpp.o
In file included from /home/a3_nm/TEMP/yaml-cpp/src/emitterstate.h:9:0,
                 from /home/a3_nm/TEMP/yaml-cpp/src/emitterstate.cpp:1:
/home/a3_nm/TEMP/yaml-cpp/src/ptr_stack.h: In member function ‘void 
ptr_stack<T>::push(std::auto_ptr<T>)’:
/home/a3_nm/TEMP/yaml-cpp/src/ptr_stack.h:29:20: error: ‘NULL’ was not 
declared in this scope
make[2]: *** [CMakeFiles/yaml-cpp.dir/src/emitterstate.cpp.o] Error 1
make[1]: *** [CMakeFiles/yaml-cpp.dir/all] Error 2
make: *** [all] Error 2

Suggested fix:
I was able to fix that by adding an "#include <cstddef>" to ptr_stack.h and 
ptr_vector.h. With this, the build succeeds and make test also succeeds. It 
seems that it would be safer to add these includes, unless what I did above is 
horribly wrong for some reason.

Original issue reported on code.google.com by a...@a3nm.net on 4 Aug 2011 at 6:18

GoogleCodeExporter commented 8 years ago
Thanks, fixed (r487).

What  OS/version of gcc are you using? I'm pretty sure <cstdlib> should define 
NULL as well.

Original comment by jbe...@gmail.com on 4 Aug 2011 at 6:48

GoogleCodeExporter commented 8 years ago
Actually, I was using the 0.2.6 release and not the one from the repos, so I 
did not have the cstdlib includes which were added in the meantime. I tested 
r486 and it compiles fine, and cstdlib is indeed supposed to define NULL, so I 
guess there is actually no need to fix anything. Sorry about that. (Maybe you 
should do a new release if 0.2.6 doesn't compile with gcc 4.6.)

Thanks for the quick reply!

Original comment by a...@a3nm.net on 4 Aug 2011 at 8:42

GoogleCodeExporter commented 8 years ago
You're probably right. I'll try to get 0.2.7 out reasonably soon - alas, I've 
been a bit busy lately!

Original comment by jbe...@gmail.com on 4 Aug 2011 at 9:10

GoogleCodeExporter commented 8 years ago
No problem at all--take your time, and thanks for your help in this!

Original comment by a...@a3nm.net on 4 Aug 2011 at 9:15