Thread overview
Importing KERNEL32 functions
Nov 27, 2004
Asaf Karagila
Nov 27, 2004
h3r3tic
Nov 27, 2004
Lars Ivar Igesund
Nov 27, 2004
Asaf Karagila
(OT) Re: Importing KERNEL32 functions
Nov 27, 2004
h3r3tic
November 27, 2004
Hi,
i am trying to import OutputDebugString to help myself with some debugging,
so i can output the source code between the lines, and so i'll know where is
the bound of each line in the code.
the problem is, it won't link.

" Error 42: Symbol Undefined _OutputDebugString@4" that's the error i get.

this is the code i use:

   import std.c.windows.windows;
   extern (Windows)
   void OutputDebugString(char *lpString);

do i need to pass the linker some lib files or something like that ? or is it something within the code ?

- Asaf.


November 27, 2004
This compiles:

<code>
import std.c.windows.windows;

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

void main()
{
	OutputDebugStringA("foobar");
}
</code>

AFAIK, some WinAPI functions are defined as .*A or .*W
The A functions take normal char params, while W take utf16 (wchar) params.
When executed though, I don't see 'foobar' displayed...



Asaf Karagila wrote:
> Hi,
> i am trying to import OutputDebugString to help myself with some debugging,
> so i can output the source code between the lines, and so i'll know where is the bound of each line in the code.
> the problem is, it won't link.
> 
> " Error 42: Symbol Undefined _OutputDebugString@4" that's the error i get.
> 
> this is the code i use:
> 
>    import std.c.windows.windows;
>    extern (Windows)
>    void OutputDebugString(char *lpString);
> 
> do i need to pass the linker some lib files or something like that ?
> or is it something within the code ?
> 
> - Asaf.
November 27, 2004
h3r3tic wrote:

> 
> AFAIK, some WinAPI functions are defined as .*A or .*W
> The A functions take normal char params, while W take utf16 (wchar) params.

The C Windows headers use defines to choose either the *A or *W version, depending on whether Unicode support should be used or not. In C, you don't need to supply this last letter, but no similar aliases are set up in the windows import files in phobos.

> When executed though, I don't see 'foobar' displayed...

I think this function is for output in debuggers.

Lars Ivar Igesund
November 27, 2004
yes,
this function is to output the string to the debugger. if no debugger is
present,
nothing happens.
that way, no matter what debugger i use, it will notify me when i start
something
(by my own code of course..)
but anyway, it's working now. i just forgot the A at the end of it since i'm
not used
to have it around..

"Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:coaplf$2t5n$1@digitaldaemon.com...
> h3r3tic wrote:
>
>>
>> AFAIK, some WinAPI functions are defined as .*A or .*W
>> The A functions take normal char params, while W take utf16 (wchar)
>> params.
>
> The C Windows headers use defines to choose either the *A or *W version, depending on whether Unicode support should be used or not. In C, you don't need to supply this last letter, but no similar aliases are set up in the windows import files in phobos.
>
>> When executed though, I don't see 'foobar' displayed...
>
> I think this function is for output in debuggers.
>
> Lars Ivar Igesund


November 27, 2004
Lars Ivar Igesund wrote:
> h3r3tic wrote:
> 
>>
>> AFAIK, some WinAPI functions are defined as .*A or .*W
>> The A functions take normal char params, while W take utf16 (wchar) params.
> 
> 
> The C Windows headers use defines to choose either the *A or *W version, depending on whether Unicode support should be used or not. (...)


Ooops, yeah... That's what I meant... I just havent expressed myself clearly :/ Yeah, I remember these macros #ifdef UNICODE ;)
Thanks for clearing it up.