(SOLVED) macro _WIN32_WINNT return wrong

General FreeBASIC programming questions.
Post Reply
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

(SOLVED) macro _WIN32_WINNT return wrong

Post by VANYA »

Hi All!

Why does the _WIN32_WINNT macro on a Windows 7 system return & h502? Must return &h601 https://docs.microsoft.com/ru-ru/cpp/po ... ew=vs-2017

result command VER in the console:
Microsoft Windows [Version 6.1.7601]
Compiler incorrectly returns version windows
Last edited by VANYA on Mar 09, 2019 2:30, edited 1 time in total.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: macro _WIN32_WINNT return wrong

Post by VANYA »

Probably many did not understand ...

I'm talking about a serious compiler error, due to which data from 70 headers (where this macro is used) will be inaccessible for windows systems starting with Windows Vista and higher!
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: macro _WIN32_WINNT return wrong

Post by fxm »

???

Code: Select all

#include "windows.bi"
Print _WIN32_WINNT
Microsoft Windows [version 10.0.17763.348]
(c) 2018 Microsoft Corporation. Tous droits réservés.
1282
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: macro _WIN32_WINNT return wrong

Post by dodicat »

Hi VANYA
It was discussed here
viewtopic.php?f=14&t=26930&p=250229&hil ... 2A#p250229

Probably should have put the new definition at the head of windows.bi for version 1.06, but it will probably be fixed now.

from andykmv:

Code: Select all

#define _WIN32_WINNT &h0602
#include "windows.bi"

print hex(_WIN32_WINNT)
Dim DynamicTimeZoneInfo As DYNAMIC_TIME_ZONE_INFORMATION
GetDynamicTimeZoneInformation(@DynamicTimeZoneInfo)
Print DynamicTimeZoneInfo.TimeZoneKeyName
sleep
  

Code: Select all

602
GMT Standard Time  
What do you get?
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: macro _WIN32_WINNT return wrong

Post by VANYA »

Hi All!
Microsoft Windows [version 10.0.17763.348]
(c) 2018 Microsoft Corporation. Tous droits réservés.

1282
Yes, hex(1282) = &h502 = Windows Server 2003
#define _WIN32_WINNT &h0602
#include "windows.bi"
Yes, adding a constant before #include "windows.bi" solves the problem, but is it really correct? It seems to me that the compiler should determine the version of Windows itself and, on the basis of this, draw a conclusion about the inclusion of headers. I understand that experienced programmers will not stop at this problem (there are a lot of ways to create a bicycle), but what about newcomers? Every time ask a question on the forum or immediately look for another compiler?
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: macro _WIN32_WINNT return wrong

Post by dodicat »

fbide gives me
Windows NT 6.2 (build 9200)
For my win 10 ( Microsoft Windows [Version 10.0.17134.590])
But that is bye the way.
My win 10 is broken after fidelling around with the suspected malware GoRc.exe in fb 1.06.
But I have no other real choice, it seems that win 8.1 is on the way out, and three versions of win 10 reign supreme at the moment.
Of course everybody else in the known universe is in the same boat.
Anyway, happy cycling VANYA.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: macro _WIN32_WINNT return wrong

Post by MrSwiss »

dodicat wrote:Windows NT 6.2 (build 9200)
Aka: Windows 8.0 (Win 8.1 = NT 6.3)
Seems, that fbide is not interpreting correctly ... (never liked it, anyway).
sancho3
Posts: 358
Joined: Sep 30, 2017 3:22

Re: macro _WIN32_WINNT return wrong

Post by sancho3 »

FBEdit on Windows 7
confirm &h502.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: macro _WIN32_WINNT return wrong

Post by jj2007 »

Win7-64 should be version 6.1, build 7601 but the macro returns 1282.
Josep Roca
Posts: 564
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: macro _WIN32_WINNT return wrong

Post by Josep Roca »

Which macro? _WIN32_WINNT is not a macro but a constant. Therefore, it will hold whatever value you assign to it.

If you don't define it, it will have a default value of &h0502.

Code: Select all

#ifndef _WIN32_WINNT
	const _WIN32_WINNT = &h0502
#endif
#ifndef WINVER
	const WINVER = _WIN32_WINNT
#endif
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: macro _WIN32_WINNT return wrong

Post by VANYA »

Josep Roca wrote:Which macro? _WIN32_WINNT is not a macro but a constant. Therefore, it will hold whatever value you assign to it.

If you don't define it, it will have a default value of &h0502.

Code: Select all

#ifndef _WIN32_WINNT
	const _WIN32_WINNT = &h0502
#endif
#ifndef WINVER
	const WINVER = _WIN32_WINNT
#endif
WOW! I really thought that the Windows version is determined by the compiler. And this is a constant :)))))))))
I am ashamed. The question is closed. Thanks Josep Roca for the cold shower!
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: (SOLVED) macro _WIN32_WINNT return wrong

Post by jj2007 »

To clarify one more bit: It's a constant because YOU instruct the compiler which is your target platform. So, if you are working on an application that is supposed to run on a thousand very, very old Windows XP machines, then you tell the compiler "hey, this is old stuff, please do not use functions that do not exist on such old machines".
Post Reply