The following code works on Linux/Mac but not Windows. Is there
something I should realize about ArgumentParser and ApplicationUsage?
Maybe it's some Windows/VS2008 thing I've missed?
---------------------------------
#include <osg/ArgumentParser>
#include <string>
int main(int argc, char * argv[])
{
std::string name("Fred");
osg::ArgumentParser arguments(&argc, argv);
osg::ApplicationUsage *au;
au = arguments.getApplicationUsage();
// the next two lines cause runtime errors on Window
au->setApplicationName(name);
std::string cmdLineName = arguments.getApplicationName();
return 0;
}
---------------------------------
The au->setApplicationName(name) line gives the error:
Unhandled exception at 0x76bc42eb foo.exe MicrosoftC++ exception:
std::bad_alloc at memory location 0x0018f37c..
commenting that line out results in the next line producing:
arguments.getApplicationName() causes "Unhandled Exception at
0xHexAddress in foo.exe 0xC0000005: Access violation reading location
0xccccccc0."
This is setup as a Windows Console App in VS2008.
I can set a breakpoint on the first line and see that argv[0] and argc
are set reasonably.
Stepping forward I note that the constructor for ApplicationUsage
doesn't initialize _applicationName. Visual Studio debugger notes <Bad
Ptr> on au->_applicationName before the call to:
au->setApplicationName(name)
Odd since _applicationName is declared:
std::string _applicationName;
Lee
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org