05-31-2012 10:51 PM
I'm getting a strange result when using "size_t" variable types in my applications. "size_t" is defined in the C libs <stdlib.h> and <stddef.h>. Typically when you're working with C++ though, its more common to include <cstdlib> and <cstddef>, which usually just act as references back to the C libs. Unfortunately, this doesn't work as expected (for me anyway) and I explicitly have to include the C libs, ie the C++ libs don't seem to do anything. It obviously has a trivial work around, but it took awhile to figure out and I'm still not sure why it doesn't work. I'm using NDK 2.0.1.
size_t helloWorld = 0;
std::cout << "helloWorld " << helloWorld << std::endl;
qcc -Vgcc_ntox86 -lang-c++ -I/home/preet/bbndk-2.0.1/target/qnx6/usr/include/
hello.cpp: In function 'int main()':
hello.cpp:5: error: 'size_t' was not declared in this scope
hello.cpp:5: error: expected ';' before 'helloWorld'
hello.cpp:6: error: 'helloWorld' was not declared in this scope
If you replace <cstdlib> with <stdlib.h> in hello.h it'll compile fine... any ideas why this happens?
Solved! Go to Solution.