Thread overview
OutputDebugString()
Mar 13, 2015
Robert M. Münch
Mar 13, 2015
Adam D. Ruppe
Mar 14, 2015
Robert M. Münch
Mar 14, 2015
Jonathan M Davis
Mar 15, 2015
Robert M. Münch
Mar 13, 2015
Matt
Mar 13, 2015
Kagamin
March 13, 2015
Hi, I want to use the Windows OutputDebugString() which is not defined anywhere.

How do I declare such missing Windows API functions myself? And with which libaries do I then need to link? Does DMD contain all necessary Windows link libs or am I supposed to get them myself?

So, it's not clear what to do if a Windows API function is missing.

And, how can I contribute new declared ones to get them integrated into the standard distribution?

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

March 13, 2015
On Friday, 13 March 2015 at 21:12:52 UTC, Robert M. Münch wrote:
> How do I declare such missing Windows API functions myself?

In the file you want to use it, you can just write

extern(Windows) void OutputDebugStringA(in char*);

and it should work... or whatever the signature is, check msdn, and remember the ones that take strings tend to need A or W for the ascii or Unicode variants.

dmd comes with a bunch of windows lib link files but not all of them. This one should work though. Just add the file, e.g. user32.lib, to the compile command line. You can also do

pragma(lib, "user32");

and such in the main D file itself you are building and it will add automatically.
March 13, 2015
On Friday, 13 March 2015 at 21:12:52 UTC, Robert M. Münch wrote:
> Hi, I want to use the Windows OutputDebugString() which is not defined anywhere.
>
> How do I declare such missing Windows API functions myself? And with which libaries do I then need to link? Does DMD contain all necessary Windows link libs or am I supposed to get them myself?
>
> So, it's not clear what to do if a Windows API function is missing.
>
> And, how can I contribute new declared ones to get them integrated into the standard distribution?

I'm pretty sure the correct way to do it is as follows:

---

import core.sys.windows.windows;

extern (Windows) OutputDebugString( LPCTSTR );
/// Add other externs here

---
March 13, 2015
On Friday, 13 March 2015 at 21:12:52 UTC, Robert M. Münch wrote:
> Hi, I want to use the Windows OutputDebugString() which is not defined anywhere.

The declaration can be already part of WindowsAPI project: https://github.com/AndrejMitrovic/WindowsAPI just see it there.

> How do I declare such missing Windows API functions myself? And with which libaries do I then need to link?

This function has rather unique implementation too. Are you sure, you don't want to see its MSDN entry?
March 14, 2015
On 2015-03-13 21:19:07 +0000, Adam D. Ruppe said:

> In the file you want to use it, you can just write
> 
> extern(Windows) void OutputDebugStringA(in char*);
> 
> and it should work... or whatever the signature is, check msdn, and remember the ones that take strings tend to need A or W for the ascii or Unicode variants.

Hi Adam, thanks that worked. Pretty easy.

Now, just need to check why I don't see any debug output but that's not a DMD issue ;-).

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

March 14, 2015
On Saturday, March 14, 2015 17:49:10 Robert M. Münch via Digitalmars-d-learn wrote:
> Now, just need to check why I don't see any debug output but that's not a DMD issue ;-).

In case you didn't know, if you're not running the program in visual studio, you should see the output in in DebugView:

https://technet.microsoft.com/en-us/library/bb896647.aspx

- Jonathan M Davis


March 15, 2015
On 2015-03-14 22:55:57 +0000, Jonathan M Davis via Digitalmars-d-learn said:

> In case you didn't know, if you're not running the program in visual studio,
> you should see the output in in DebugView:
> 
> https://technet.microsoft.com/en-us/library/bb896647.aspx

Hi, yes I know, nevertheless thanks for letting me know. The problem was, that I needed the newest version for Win-10 and than it worked again.

DebugView is really a great tool, especially if you want to debug DLLs.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster