Unfortunately, I'm not able to compile this. The first time, I was using the non-hmg minigui distribution, which is missing the HMG include files.
So I went ahead and installed the hmg.3.4.4 download, and set a path to c:\hmg.3.4.4\MINGW\bin, since the hbmk2.exe didn't recognize the existing path to c:\bc5\bin.
But compiling returns an error:
Code: Select all
call ..\..\HARBOUR\bin\hbmk2 -b OurPing.prg -oOurPing -ic:\hmg.3.4.4\INCLUDE
Harbour 3.2.0dev (r1703241902)
Copyright (c) 1999-2016, http://harbour-project.org/
Compiling 'OurPing.prg'...
Lines 157, Functions/Procedures 1
Generating C source output to 'C:\Users\UserName\AppData\Local\Temp\hbmk_3bj9zf.dir\OurPing.c'... Done.
In file included from OurPing.prg:55:0:
OurPing.prg: In function 'HB_FUN_HMG_GETSYSTEMERRORMSG':
OurPing.prg:144:17: warning: passing argument 1 of 'hb_osStrU16Decode' from incompatible pointer type [-Wincompatible-pointer-types]
c:/hmg.3.4.4/INCLUDE/HMG_UNICODE.h:77:56: note: in definition of macro 'HMG_WCHAR_TO_CHAR'
#define HMG_WCHAR_TO_CHAR(c) hb_osStrU16Decode(c) // return CHAR
^
OurPing.prg:144:7: note: in expansion of macro 'HMG_retc'
In file included from OurPing.prg:49:0:
C:/hmg.3.4.4/HARBOUR/include/hbapi.h:1226:31: note: expected 'const HB_WCHAR * {aka const short unsigned int *}' but argument is of type 'TCHAR * {aka char *}'
extern HB_EXPORT char * hb_osStrU16Decode( const HB_WCHAR * pszNameW );
^
C:/Users/UserName/AppData/Local/Temp/hbmk_3bj9zf.dir/OurPing.o:OurPing.c:(.data+0x78): undefined reference to `HB_FUN_GETSYSTEMERRORMSG'
collect2.exe: error: ld returned 1 exit status
hbmk2: Error: Running linker. 1
gcc.exe C:/Users/UserName/AppData/Local/Temp/hbmk_3bj9zf.dir/OurPing.o C:/Users/UserName/AppData/Local/Temp/hbmk_3bj9zf.dir/hbmk_8h94x3.o -mconsole -Wl,--start-group -lhbextern -lhbdebug -lhbvm -lhb
rtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon
-lhbmainstd -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbp
cre -lhbzlib -Wl,--end-group -oOurPing.exe -LC:/hmg.3.4.4/HARBOUR/lib/win/mingw
hbmk2: Error: Referenced, missing, but unknown function(s): GETSYSTEMERRORMSG()
It's referring to this, at line 144:
It's possible that the multiple paths for c:\minigui, c:\bc5, c:\hb32, and c:\hmg.3.4.4 are screwing up the compiler's search for the approrpriate include file. But I wanted to get an opinion about it, before removing those paths with Rapid Environment Editor.
srvet_claudio wrote: ↑Sat Aug 15, 2020 4:33 pm
Hi,
see:
Code: Select all
#include "hmg.ch"
Function Main
LOCAL nError := 33
msginfo( { nError, " --> ", HMG_GetSystemErrorMsg( nError ) } );
Return
#pragma BEGINDUMP
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"
#include <windows.h>
#include <tchar.h>
#include "hbapi.h"
HB_FUNC( HMG_GETSYSTEMERRORMSG ){
DWORD dw = hb_parnl( 1 );
LPVOID lpMsgBuf;
TCHAR n = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
if( n > 0 ){
TCHAR * cBuffer = hb_xgrab( (n + 1)* sizeof( TCHAR ) );
lstrcpy( cBuffer, (TCHAR*) lpMsgBuf );
HMG_retc( cBuffer );
hb_xfree( cBuffer );
}
else
hb_retc( NULL );
LocalFree(lpMsgBuf);
}
#pragma ENDDUMP