global static pointer variable in DLL
Bill Baxter
dnewsgroup at billbaxter.com
Sun May 18 15:22:51 PDT 2008
Zarathustra wrote:
> Bill Baxter Wrote:
>
>> Zarathustra wrote:
>>> torhu Wrote:
>>>
>>>> Zarathustra wrote:
>>>>> I have a C DLL whih global static pointer variables.
>>>>> When I use this DLL with C everything is ok, but when I try to use it (DLL) with D I receive Acces Violation errors.
>>>>> I do not have any idea what is wrong. If something is inexplicable, You will ask. Please help.
>>>>>
>>>>> simple example code in dll
>>>>> gl2ps is global pointer
>>>>> [code]
>>>>> if(gl2ps){/*
>>>>> never true in C but true in D*/}
>>>>> [/code]
>>>>>
>>>> It's a bit hard to know what the problem is when you don't post some
>>>> more code. How do you declare gl2ps in D? If it's in a C DLL, it
>>>> should look like this:
>>>>
>>>> export extern extern (C) void* gl2ps;
>>>>
>>>> Replace void* with the correct type, of course.
>>>>
>>>> And in the C code IIRC it should be:
>>>>
>>>> __declspec(dllexport) void* gl2ps;
>>> gl2ps is not exported because it is not necessary beyond DLL.
>>> gl2ps declaration in DLL is following:
>>> static GL2PScontext *gl2ps = NULL;
>>> for example:
>>> The crash occurs in exported gl2psBeginPage function. (in attachment)
>>> Declaration of above function in D is following:
>>> extern (C) GLint gl2psBeginPage; // static linking
>>>
>>> DLL is little long but very simple, so I can send it to you.
>> You might be interested in my Frankenstein's hybrid of gl2ps and OGLE.
>> It allows basically allows you to do what gl2ps does, but
>> non-invasively. I.e. you can gl2ps an OpenGL screen without modifying
>> any source code.
>>
>> --bb
> It sounds good.
> Could You tell something more about your Frankenstein's hybrid? Where can i find more information about it?
Just something I whipped up because I needed it. There's no docs or
anything at this point (though OGLE, which it is based on can be found
here: http://ogle.eyebeamresearch.org/
Put the OpenGL32.dll from in this zip into your program's exe dir
http://www.billbaxter.com/etc/GLGrabber-2008-02-02.zip
And copy a gliconfig.ini from in there to your exe dir too. Read the
gliconfig.ini for some info. I think by default Ctrl-Shift-F12 is the
screen-grab-to-svg keystroke. You can change the settings in
gliConfig.ini to save to PS if you prefer.
--bb
More information about the Digitalmars-d-learn
mailing list