Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use external HWND function [closed]

Tags:

c

winapi

I was making a Windows application but I get an issue. When I try to extern a function with HWND as a parameter, the linker report an error:

undefined symbol void far htest( HWND__ const near * )

I'm using Win16 and not Win32 at this time, so the code is going to be 16-bit.

test.cpp:

#define STRICT
#include <windows.h>
#include <afxext.h>
#include <stdio.h>
#include "test2.h"

LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    htest(hwnd);
}

test2.h:

extern void htest(HWND hwnd);

test2.cpp:

#include <windows.h>
    
void htest(HWND hwnd)
{
    /* code here */
}
like image 726
Codesynth Avatar asked Dec 21 '25 13:12

Codesynth


1 Answers

It looks like the issue comes from defining STRICT. When I looked in the win16.h header, which declares HWND, it checks for STRICT which I defined in test.cpp. If STRICT is not defined, HWND is declared as UINT. But if it is defined, HWND is declared as a structure.

For the solution, I added #define STRICT to test2.cpp.

like image 92
Codesynth Avatar answered Dec 24 '25 04:12

Codesynth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!