|
From: Eli Z. <el...@gn...> - 2015-02-07 19:39:12
|
> Date: Sat, 07 Feb 2015 12:29:32 -0600
> From: Carl Sturtivant <stu...@gm...>
>
> #include <windows.h>
> #include <stdio.h>
>
> int main() {
> char buf[1024];
> DWORD sz = 1024;
> //GetComputerNameA( buf, &sz);
> GetComputerNameExA( 1, buf, &sz);
> printf( "\"%s\"\n", buf);
> }
> ========
>
> msys $ gcc -o gethostname gethostname.c
> C:\temp\ccmcT7xy.o:gethostname.c:(.text+0x31):
> undefined reference to `GetComputerNameExA'
> collect2.exe: error: ld returned 1 exit status
The prototype of GetComputerNameExA is guarded by
#if (_WIN32_WINNT >= 0x0500)
So you need to
#define _WIN32_WINNT 0x0500
before including <window.h>.
|