Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
missing WINVER variable
Raijinsetsu:
You're right mort, it's there in the windef.h, but it's set to 0x0400, which is windows 95... Who uses win95 anyways?
If I define my own WINVER on the command line, it works.
Thanks
kkez:
--- Quote from: thomas on July 15, 2006, 10:44:23 am ---This:
--- Quote ---When using Visual Studio, these variables are in the compiler, so you don't have to define them.
--- End quote ---
is certainly not true. It cannot be true. If Visual Studio was setting WINVER=0x501 as a general rule, then you could not write programs that work on anything older than Windows XP.
--- End quote ---
Actually those flags (_WINVER, _WIN32_WINNT, _WIN32_IE) only enable some structure, structure members or flags that are only available under a certain version of windows. If you define them but do not use any of these new elements then you're ok with every windows version :)
thomas:
--- Quote ---So this means that the missing WINVER macro is actually a problem with CygWin/MinGW
--- End quote ---
Problem is not the correct word. MinGW (or gcc in general) is a compiler that is first and for all designed for compatibility and standard compliance. Only after this, it is designed for things like optimisations or system-dependent features.
It has to work, and it has to be right. Everything else is second line.
The default value of WINVER chosen by MinGW is a safe value that guarantees it works everywhere. If you accidentially use something that would prevent your program from running on older, then you will know. It will not compile without errors and mysteriously crash later (or fail due to a missing DLL), but it will tell you before things get nasty on the target PC.
That way, the developer can decide what to do in time (either change minimum requirements or use different functions).
This is a very good strategy, it saves you a lot of support work and headaches later.
If you're positive about not wanting to support anything older than Windows XP, you can always -DWINVER=0x501 or anything in your project settings, it is neither obscure nor hidden, nor anything of that kind, and it works just fine. It will just not work on an older OS, but you know it won't.
--- Quote ---Who uses win95 anyways?
--- End quote ---
Where I live, almost nobody uses Windows 95/98/ME any more (although a few people exist who still do). It may be the same where you live.
However, you have to take into account that the majority of people that live on this planet are not exactly as lucky as you and me.
In fact, for far more than two thirds of this planet's population, a Pentium III with Windows 98 is something so surreal that they would not even think about ever owning one. Therefore, you should not assume that nobody uses Windows 9x any more.
thomas:
--- Quote ---If you define them but do not use any of these new elements then you're ok with every windows version
--- End quote ---
Ah sorry, did not see this before.
Although you are technically right with this, I still cannot agree.
WINVER can be thought of as a parachute. It is a measure that is somewhat similar to type checking in the compiler.
Technically, type checking is absolutely useless and it is plain annoying, too. It is a lot of extra work which you actually don't need. You can do everything with void* all over the place, and you can mix char, int, and long all the time. Yeah, you know that if you copy a long value to a char variable, then it would better be smaller than 255. So what, you remember that. Why is the compiler so pedantic about this!
Well, the truth is that we are human beings, and as such we make mistakes. Type checking makes sure we detect these mistakes early.
The same goes for WINVER. If we never use a non-supported function, then all is fine. However, sooner or later, you will forget that you may not use one particular function, and you will use it.
If there is no such thing as WINVER, then the compiler will build your program just fine (supposed your headers and libraries are up to date). But then, after you have spent a lot of time and money, thousands of support calls keep coming in and people ask their money back because your program does not work for them (other than expected).
Navigation
[0] Message Index
[*] Previous page
Go to full version