www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - global static pointer variable in DLL

reply Zarathustra <adam.chrapkowski gmail.com> writes:
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]
May 17 2008
next sibling parent reply torhu <no spam.invalid> writes:
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;
May 17 2008
parent reply Zarathustra <adam.chrapkowski gmail.com> writes:
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.
May 17 2008
next sibling parent reply torhu <no spam.invalid> writes:
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]
 
 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.
When you say 'crash', do you mean that gl2ps is NULL on line 11 of the attached file? Then the problem is likely be in the code that initializes gl2ps, not in the gl2psBeginPage function.
May 17 2008
parent reply Zarathustra <adam.chrapkowski gmail.com> writes:
torhu 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]
 
 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.
When you say 'crash', do you mean that gl2ps is NULL on line 11 of the attached file? Then the problem is likely be in the code that initializes gl2ps, not in the gl2psBeginPage function.
Oh, I find out something. The most crashes occur in similar calls (in DLL) like following: ________________________________________________________ offs += fprintf(gl2ps->stream, "%%PDF-1.4\n"); ________________________________________________________ it looks like DLL haven't got access to FILE(gl2ps->stream), but why? The FILE is operand of gl2psBeginPage. Call of gl2psBeginPage function in my D code is in following function: ________________________________________________________ extern (C) void SaveFile(){ FILE* fp; int state = GL2PS_OVERFLOW; int buffsize = 0; try{ fp = fopen("out.pdf", "wb"); while(state == GL2PS_OVERFLOW){ buffsize += 1024*1024; gl2psBeginPage( "test", "gl2psTestSimple", null, GL2PS_PDF, GL2PS_SIMPLE_SORT, GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT, GL_RGBA, 0, null, 0, 0, 0, buffsize, fp, "out.pdf" ); RenderFrame(); state = gl2psEndPage(); } fclose(fp); MessageBoxA(null, "File saved", "Information", MB_OK | MB_ICONINFORMATION); } catch(Object o){ MessageBoxA(null, cast(char*)o.toString(), "Critical Error", MB_OK | MB_ICONERROR); } } ________________________________________________________ exactly: gl2ps->stream = fp;
May 18 2008
parent torhu <no spam.invalid> writes:
Zarathustra wrote:
 
 Oh, I find out something.
 The most crashes occur in similar calls (in DLL) like following:
 ________________________________________________________
 offs += fprintf(gl2ps->stream, "%%PDF-1.4\n");
 ________________________________________________________
 it looks like DLL haven't got access to FILE(gl2ps->stream), but why?
 The FILE is operand of gl2psBeginPage.
 Call of gl2psBeginPage function in my D code is in following function:
 ________________________________________________________
 extern (C) void
 SaveFile(){
 	FILE* fp;
 	int state = GL2PS_OVERFLOW;
 	int buffsize = 0;
             		
 	try{
 		fp = fopen("out.pdf", "wb");
 		while(state == GL2PS_OVERFLOW){
 			buffsize += 1024*1024;
 
 			gl2psBeginPage(
 				"test", 
 				"gl2psTestSimple", 
 				null, 
 				GL2PS_PDF, 
 				GL2PS_SIMPLE_SORT,
 				GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
 				GL_RGBA, 
 				0, 
 				null, 
 				0, 
 				0, 
 				0, 
 				buffsize, 
 				fp, 
 				"out.pdf"
 			);
 			
 			RenderFrame();
 			state = gl2psEndPage();
 		}
 		fclose(fp);
 		MessageBoxA(null, "File saved", "Information", MB_OK | MB_ICONINFORMATION);
 	}
 	catch(Object o){
 		MessageBoxA(null, cast(char*)o.toString(), "Critical Error", MB_OK |
MB_ICONERROR);
 	}
 }
 ________________________________________________________
 exactly: gl2ps->stream = fp;
 
Have you tried debugging this code with ddbg, and checked what the actual values of gl2ps and gl2ps->stream are when it crashes? http://ddbg.mainia.de/
May 18 2008
prev sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
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
May 17 2008
parent reply Zarathustra <adam.chrapkowski gmail.com> writes:
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?
May 18 2008
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
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
May 18 2008
prev sibling next sibling parent Zarathustra <adam.chrapkowski gmail.com> writes:
torhu Wrote:

 Zarathustra wrote:
 
 Oh, I find out something.
 The most crashes occur in similar calls (in DLL) like following:
 ________________________________________________________
 offs += fprintf(gl2ps->stream, "%%PDF-1.4\n");
 ________________________________________________________
 it looks like DLL haven't got access to FILE(gl2ps->stream), but why?
 The FILE is operand of gl2psBeginPage.
 Call of gl2psBeginPage function in my D code is in following function:
 ________________________________________________________
 extern (C) void
 SaveFile(){
 	FILE* fp;
 	int state = GL2PS_OVERFLOW;
 	int buffsize = 0;
             		
 	try{
 		fp = fopen("out.pdf", "wb");
 		while(state == GL2PS_OVERFLOW){
 			buffsize += 1024*1024;
 
 			gl2psBeginPage(
 				"test", 
 				"gl2psTestSimple", 
 				null, 
 				GL2PS_PDF, 
 				GL2PS_SIMPLE_SORT,
 				GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
 				GL_RGBA, 
 				0, 
 				null, 
 				0, 
 				0, 
 				0, 
 				buffsize, 
 				fp, 
 				"out.pdf"
 			);
 			
 			RenderFrame();
 			state = gl2psEndPage();
 		}
 		fclose(fp);
 		MessageBoxA(null, "File saved", "Information", MB_OK | MB_ICONINFORMATION);
 	}
 	catch(Object o){
 		MessageBoxA(null, cast(char*)o.toString(), "Critical Error", MB_OK |
MB_ICONERROR);
 	}
 }
 ________________________________________________________
 exactly: gl2ps->stream = fp;
 
Have you tried debugging this code with ddbg, and checked what the actual values of gl2ps and gl2ps->stream are when it crashes? http://ddbg.mainia.de/
I converted all gl2ps code to d and then started debugging with ddbg. I have got a problem with allocating memory. I have got the following code: if(gl2ps.bgcolor is cast(GL2PSrgba*)null){ gl2ps.bgcolor = cast(GL2PSrgba*)malloc(GL2PSrgba.sizeof); } and error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at ?Alloc RTLPool QAEPAXXZ (0x0042e8a9) thread(5368) I don't know what does it mean.
May 25 2008
prev sibling parent reply Zarathustra <adam.chrapkowski gmail.com> writes:
torhu Wrote:

 Zarathustra wrote:
 
 Oh, I find out something.
 The most crashes occur in similar calls (in DLL) like following:
 ________________________________________________________
 offs += fprintf(gl2ps->stream, "%%PDF-1.4\n");
 ________________________________________________________
 it looks like DLL haven't got access to FILE(gl2ps->stream), but why?
 The FILE is operand of gl2psBeginPage.
 Call of gl2psBeginPage function in my D code is in following function:
 ________________________________________________________
 extern (C) void
 SaveFile(){
 	FILE* fp;
 	int state = GL2PS_OVERFLOW;
 	int buffsize = 0;
             		
 	try{
 		fp = fopen("out.pdf", "wb");
 		while(state == GL2PS_OVERFLOW){
 			buffsize += 1024*1024;
 
 			gl2psBeginPage(
 				"test", 
 				"gl2psTestSimple", 
 				null, 
 				GL2PS_PDF, 
 				GL2PS_SIMPLE_SORT,
 				GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
 				GL_RGBA, 
 				0, 
 				null, 
 				0, 
 				0, 
 				0, 
 				buffsize, 
 				fp, 
 				"out.pdf"
 			);
 			
 			RenderFrame();
 			state = gl2psEndPage();
 		}
 		fclose(fp);
 		MessageBoxA(null, "File saved", "Information", MB_OK | MB_ICONINFORMATION);
 	}
 	catch(Object o){
 		MessageBoxA(null, cast(char*)o.toString(), "Critical Error", MB_OK |
MB_ICONERROR);
 	}
 }
 ________________________________________________________
 exactly: gl2ps->stream = fp;
 
Have you tried debugging this code with ddbg, and checked what the actual values of gl2ps and gl2ps->stream are when it crashes? http://ddbg.mainia.de/
I converted all gl2ps code to d and then started debugging with ddbg. I have got a problem with allocating memory. I have got the following code: if(gl2ps.bgcolor is cast(GL2PSrgba*)null){ gl2ps.bgcolor = cast(GL2PSrgba*)malloc(GL2PSrgba.sizeof); } and error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at ?Alloc RTLPool QAEPAXXZ (0x0042e8a9) thread(5368) I don't know what does it mean.
May 25 2008
parent reply torhu <no spam.invalid> writes:
Zarathustra wrote:
 torhu Wrote:
 
 Zarathustra wrote:
 
 Oh, I find out something.
 The most crashes occur in similar calls (in DLL) like following:
 ________________________________________________________
 offs += fprintf(gl2ps->stream, "%%PDF-1.4\n");
 ________________________________________________________
 it looks like DLL haven't got access to FILE(gl2ps->stream), but why?
 The FILE is operand of gl2psBeginPage.
 Call of gl2psBeginPage function in my D code is in following function:
 ________________________________________________________
 extern (C) void
 SaveFile(){
 	FILE* fp;
 	int state = GL2PS_OVERFLOW;
 	int buffsize = 0;
             		
 	try{
 		fp = fopen("out.pdf", "wb");
 		while(state == GL2PS_OVERFLOW){
 			buffsize += 1024*1024;
 
 			gl2psBeginPage(
 				"test", 
 				"gl2psTestSimple", 
 				null, 
 				GL2PS_PDF, 
 				GL2PS_SIMPLE_SORT,
 				GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
 				GL_RGBA, 
 				0, 
 				null, 
 				0, 
 				0, 
 				0, 
 				buffsize, 
 				fp, 
 				"out.pdf"
 			);
 			
 			RenderFrame();
 			state = gl2psEndPage();
 		}
 		fclose(fp);
 		MessageBoxA(null, "File saved", "Information", MB_OK | MB_ICONINFORMATION);
 	}
 	catch(Object o){
 		MessageBoxA(null, cast(char*)o.toString(), "Critical Error", MB_OK |
MB_ICONERROR);
 	}
 }
 ________________________________________________________
 exactly: gl2ps->stream = fp;
 
Have you tried debugging this code with ddbg, and checked what the actual values of gl2ps and gl2ps->stream are when it crashes? http://ddbg.mainia.de/
I converted all gl2ps code to d and then started debugging with ddbg. I have got a problem with allocating memory. I have got the following code: if(gl2ps.bgcolor is cast(GL2PSrgba*)null){ gl2ps.bgcolor = cast(GL2PSrgba*)malloc(GL2PSrgba.sizeof); } and error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at ?Alloc RTLPool QAEPAXXZ (0x0042e8a9) thread(5368) I don't know what does it mean.
Does it crash on the malloc line? Maybe you've got heap corruption. You could check for stray pointers or buffer overflows. Maybe someone else recognizes this error and can tell you more, because I might be completely wrong about this.
May 25 2008
parent reply Zarathustra <adam.chrapkowski gmail.com> writes:
torhu Wrote:

 Zarathustra wrote:
 torhu Wrote:
 
 Zarathustra wrote:
 
 Oh, I find out something.
 The most crashes occur in similar calls (in DLL) like following:
 ________________________________________________________
 offs += fprintf(gl2ps->stream, "%%PDF-1.4\n");
 ________________________________________________________
 it looks like DLL haven't got access to FILE(gl2ps->stream), but why?
 The FILE is operand of gl2psBeginPage.
 Call of gl2psBeginPage function in my D code is in following function:
 ________________________________________________________
 extern (C) void
 SaveFile(){
 	FILE* fp;
 	int state = GL2PS_OVERFLOW;
 	int buffsize = 0;
             		
 	try{
 		fp = fopen("out.pdf", "wb");
 		while(state == GL2PS_OVERFLOW){
 			buffsize += 1024*1024;
 
 			gl2psBeginPage(
 				"test", 
 				"gl2psTestSimple", 
 				null, 
 				GL2PS_PDF, 
 				GL2PS_SIMPLE_SORT,
 				GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
 				GL_RGBA, 
 				0, 
 				null, 
 				0, 
 				0, 
 				0, 
 				buffsize, 
 				fp, 
 				"out.pdf"
 			);
 			
 			RenderFrame();
 			state = gl2psEndPage();
 		}
 		fclose(fp);
 		MessageBoxA(null, "File saved", "Information", MB_OK | MB_ICONINFORMATION);
 	}
 	catch(Object o){
 		MessageBoxA(null, cast(char*)o.toString(), "Critical Error", MB_OK |
MB_ICONERROR);
 	}
 }
 ________________________________________________________
 exactly: gl2ps->stream = fp;
 
Have you tried debugging this code with ddbg, and checked what the actual values of gl2ps and gl2ps->stream are when it crashes? http://ddbg.mainia.de/
I converted all gl2ps code to d and then started debugging with ddbg. I have got a problem with allocating memory. I have got the following code: if(gl2ps.bgcolor is cast(GL2PSrgba*)null){ gl2ps.bgcolor = cast(GL2PSrgba*)malloc(GL2PSrgba.sizeof); } and error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at ?Alloc RTLPool QAEPAXXZ (0x0042e8a9) thread(5368) I don't know what does it mean.
Does it crash on the malloc line? Maybe you've got heap corruption. You could check for stray pointers or buffer overflows. Maybe someone else recognizes this error and can tell you more, because I might be completely wrong about this.
Ok I resolved this problem by change std.c.stdlib.malloc on std.gc.malloc. But now I still have a problem with fprintf() functions. code: ________________________________________________________ offs = fprintf(gl2ps.stream, "1 0 obj\n<<\n/Title (%s)\n/Creator (GL2PS %d.%d.%d%s, %s)\n/Producer (%s)\n", gl2ps.title, GL2PS_MAJOR_VERSION, GL2PS_MINOR_VERSION, GL2PS_PATCH_VERSION, GL2PS_EXTRA_VERSION, GL2PS_COPYRIGHT, gl2ps.producer); ________________________________________________________ Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at _strlen (0x0042a37d) thread(3380) but when I change it: code ________________________________________________________ offs = fprintf(gl2ps.stream, /*"1 0 obj\n<<\n/Title (%s)\n/Creator (GL2PS %d.%d.%d%s, %s)\n/Producer (%s)\n",*/ gl2ps.title, GL2PS_MAJOR_VERSION, GL2PS_MINOR_VERSION, GL2PS_PATCH_VERSION, GL2PS_EXTRA_VERSION, GL2PS_COPYRIGHT, gl2ps.producer); ________________________________________________________ everything is ok :/, too long string or what?
May 25 2008
parent reply "Koroskin Denis" <2korden gmail.com> writes:
On Sun, 25 May 2008 22:57:35 +0400, Zarathustra  =

<adam.chrapkowski gmail.com> wrote:

 Ok I resolved this problem by change std.c.stdlib.malloc on  =
 std.gc.malloc.
 But now I still have a problem with fprintf() functions.
 code:
 ________________________________________________________
 offs =3D fprintf(gl2ps.stream,
                  "1 0 obj\n<<\n/Title (%s)\n/Creator (GL2PS %d.%d.%d%s=
, =
 %s)\n/Producer (%s)\n",
                  gl2ps.title, GL2PS_MAJOR_VERSION, GL2PS_MINOR_VERSION=
,
                  GL2PS_PATCH_VERSION, GL2PS_EXTRA_VERSION,  =
 GL2PS_COPYRIGHT,
                  gl2ps.producer);
 ________________________________________________________
 Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at _strlen=
=
 (0x0042a37d) thread(3380)

 but when I change it:
 code
 ________________________________________________________
   offs =3D fprintf(gl2ps.stream,
                  /*"1 0 obj\n<<\n/Title (%s)\n/Creator (GL2PS  =
 %d.%d.%d%s, %s)\n/Producer (%s)\n",*/
                  gl2ps.title, GL2PS_MAJOR_VERSION, GL2PS_MINOR_VERSION=
,
                  GL2PS_PATCH_VERSION, GL2PS_EXTRA_VERSION,  =
 GL2PS_COPYRIGHT,
                  gl2ps.producer);
 ________________________________________________________
 everything is ok :/, too long string or what?
Looks like you provide a null-pointer as a string to fprintf...
May 25 2008
parent Zarathustra <adam.chrapkowski gmail.com> writes:
Koroskin Denis Wrote:

 On Sun, 25 May 2008 22:57:35 +0400, Zarathustra  
 <adam.chrapkowski gmail.com> wrote:
 
 Ok I resolved this problem by change std.c.stdlib.malloc on  
 std.gc.malloc.
 But now I still have a problem with fprintf() functions.
 code:
 ________________________________________________________
 offs = fprintf(gl2ps.stream,
                  "1 0 obj\n<<\n/Title (%s)\n/Creator (GL2PS %d.%d.%d%s,  
 %s)\n/Producer (%s)\n",
                  gl2ps.title, GL2PS_MAJOR_VERSION, GL2PS_MINOR_VERSION,
                  GL2PS_PATCH_VERSION, GL2PS_EXTRA_VERSION,  
 GL2PS_COPYRIGHT,
                  gl2ps.producer);
 ________________________________________________________
 Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at _strlen  
 (0x0042a37d) thread(3380)

 but when I change it:
 code
 ________________________________________________________
   offs = fprintf(gl2ps.stream,
                  /*"1 0 obj\n<<\n/Title (%s)\n/Creator (GL2PS  
 %d.%d.%d%s, %s)\n/Producer (%s)\n",*/
                  gl2ps.title, GL2PS_MAJOR_VERSION, GL2PS_MINOR_VERSION,
                  GL2PS_PATCH_VERSION, GL2PS_EXTRA_VERSION,  
 GL2PS_COPYRIGHT,
                  gl2ps.producer);
 ________________________________________________________
 everything is ok :/, too long string or what?
Looks like you provide a null-pointer as a string to fprintf...
Why Do you think that? When I shorten string then error don't occur. There didn't occur null pointers, I checked It before. I think that interesting is the error "_strlen". Also interesting is that, why when I execute this code with C then everything is ok. How to check what does this error exactly mean? It looks like rate of data is too big for one fprintf() call.
May 25 2008