Write To BlitzMax DebugLog From A DLL?

BlitzMax Forums/BlitzMax Programming/Write To BlitzMax DebugLog From A DLL?

Gabriel(Posted 2009) [#1]
Is it possible to output data in a DLL such that it will appear in the BlitzMax IDE Debug window? If I write to stderr with fprintf in C++ code which is linked with BMX source, then I can do this. However, writing to stderr in the DLL has no effect. Just wondered if there is another way to do that.


plash(Posted 2009) [#2]
Just use Print?


Gabriel(Posted 2009) [#3]
Nope, 'fraid not.


Brucey(Posted 2009) [#4]
However, writing to stderr in the DLL has no effect.

I've been outputing from a DLL to the console in a current project of mine - although admittedly I was using printf().


Gabriel(Posted 2009) [#5]
When you say "to the console" do you mean MaxIDE's "output" tab or do you mean an actual console window? I don't have a console window open and it wouldn't really be appropriate to have one. I was just trying to write to the IDE's debug/output window as I can with C++ code which actually gets linked. And I don't get anything in there with printf or fprintf with stderr or stdout. Maybe it's different because I'm writing the DLL in Visual Studio? Is there a project setting I have to look for to enable writing to stderr? or printf?


skidracer(Posted 2009) [#6]
A dll can have multiple processes using it (and std handles are usually allocated per process) so the solution is to simply pass the stderr handle in from the process when it initializes it's session with your dll.

Blitz programs should be able to use stdin_ etc. global variables from pub.stdc for the correct handle values.


Brucey(Posted 2009) [#7]
I was just trying to write to the IDE's debug/output

Yes, that's the one I meant.

In my DLL, I simply call printf(....); fflush(stdout);
which I found works much the same as doing the same from normal (not dll) C++.

But yeah, skid's way is probably better for more general use. Since I was just hacking in a little debug, didn't really matter in my case.


Gabriel(Posted 2009) [#8]
Oooh, I didn't know there were global variables called stdin_ stdout_ and stderr_ so that's very helpful. Thanks Skid.