Hi Butler;

It is well known problem :) I think your OSG system only compiled in release
mode and you are trying to build this example in debug mode, so program
throw bad_alloc exception. Try to build your example same build type as your
OSG system. If it is released mode you build your example in released mode
or vice versa.

Regards.

2009/6/9 Butler, Lee Mr CIV USA USAMC <lee.but...@us.army.mil>

> 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
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Ümit Uzun
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to