Have a task to call IsWindows10OrGreater function in asm x86 code. At first, I tried to include it from kernel32 lib, but than I found out that this library doesn't contain IsWindows10OrGreater function, instead it can be found in VersionHelpers.h file. So, I decided to create cpp file, include Windows.h and VersionHelpers.h file in there, and then extern IsWindows10OrGreater function in my asm file. But I got such error: LNK2001 unresolved external symbol _IsWindows10OrGreater.
IsWindows10OrGreater.cpp:
#include <Windows.h>
#include <VersionHelpers.h>
main.asm:
.686
.model flat, STDCALL
option casemap :none
extern IsWindows10OrGreater : proc
.data
wMajorVersion dw 10
wMinorVersion dw 0
wServicePackMajor dw 0
.code
Start:
push wServicePackMajor
push wMinorVersion
push wMajorVersion
call IsWindows10OrGreater
end Start
Tried to write in that cpp file a function that calls IsWindows10OrGreater function and returns it's result, but got more new errors. Still can't fix it, maybe there is another correct approach to use IsWindows10OrGreater function in asm x86 code?
Problem
This is the definition of
IsWindows10OrGreater()which is expanded to
About inline
Because it's inline,
The difference between the inline functions and macros
The following example shows a macro that converts lowercase letters to uppercase:
The intent of the expression toupper(getc(stdin)) is that a character should be read from the console device (stdin) and, if necessary, converted to uppercase.
Because of the implementation of the macro, getc is executed once to determine whether the character is greater than or equal to "a," and once to determine whether it's less than or equal to "z." If it is in that range, getc is executed again to convert the character to uppercase. It means the program waits for two or three characters when, ideally, it should wait for only one.
Inline functions remedy the problem previously described:
Output:
When to use inline functions
Note
Simple solution
From another linked question: