simple assignment statement compiles but becomes a run time error

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 18 17:44:07 PST 2015


On Sunday, 18 January 2015 at 20:07:25 UTC, weaselcat wrote:
> On Sunday, 18 January 2015 at 19:51:02 UTC, WhatMeWorry wrote:
>> On Sunday, 18 January 2015 at 19:42:33 UTC, WhatMeWorry wrote:
>>>
>>> I've got a OpenGL function returning a pointer
>>>
>>> // const GLubyte *version = glGetString(GL_VERSION);  // C++ 
>>> and openLG code
>>>
>>> // the following compiles with no errors or warnings
>>>
>>> char openglVersion[100] = 
>>> fromStringz(glGetString(GL_VERSION));
>>> // ABENDS HERE!
>>>
>>>
>>> // documentation from std.string shows
>>> // pure @system inout(char)[] fromStringz(inout(char)* 
>>> cString);
>>>
>>> // Seems pretty innocuous to me.
>>>
>>>
>>> Debugger returns:
>>> Unhandled exception at 0x76AC2F71 (KernelBase.dll) in 
>>> WhatVersionOfOpenGL.exe
>
> Hi,
>
> try replacing the fromStringz with to!string from std.conv

No cigar.

char openglVersion[100] = fromStringz(glGetString(GL_VERSION));
causes the same exception.

Thanks for suggestion.  Could (Can?) OpenGL be marking the string 
as read only?  So we can print out value put not copy it?






More information about the Digitalmars-d-learn mailing list