Hi,
I write a program in VC++ which calls a function written in assembly. The function gets four integer parameters, namely wHour, wMinute, wSecond, and wMilliseconds and returns time in milliseconds. Its works perfectly. Now I'm trying to get the local time within my assembly function
INVOKE GetLocalTime, ADDR sysTime
and have no errors during assembling but when I build my programe in VC++ I get the error: func.obj : error LNK2001: unresolved external symbol _GetLocalTime
What do I wrong?
Thanks.
I write a program in VC++ which calls a function written in assembly. The function gets four integer parameters, namely wHour, wMinute, wSecond, and wMilliseconds and returns time in milliseconds. Its works perfectly. Now I'm trying to get the local time within my assembly function
INVOKE GetLocalTime, ADDR sysTime
and have no errors during assembling but when I build my programe in VC++ I get the error: func.obj : error LNK2001: unresolved external symbol _GetLocalTime
What do I wrong?
Thanks.
I don't know why but you are trying to link the function GetLocalTime as a C one when it's a stdcall one...
Could you post your code?
Regards,
Mariano.
:alright:
Could you post your code?
Regards,
Mariano.
:alright:
oleg,
Just as Eternal Idol Birmingham said, GetLocalTime is a stdcall function. For more information, have a look at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getlocaltime.asp
Just as Eternal Idol Birmingham said, GetLocalTime is a stdcall function. For more information, have a look at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getlocaltime.asp
First of all thanks for your attention. I enclose my code.
Regards,
oleg
Regards,
oleg
Done, I've fixed it but with windows.inc and not that Irvine2.inc that I don't have. I've tested it and it works.
The problem is the parameter convention, you have declared C in the asm source code which is fine to link to the main.cpp but I will not link to the API. So I've changed that to stdcall and replaced your old C calling of mytime to a stdcall one and now it works.
func.asm:
.model flat,stdcall
include windows.inc
main.cpp:
extern "C" int __stdcall mytime(int,int,int,int);
I've attached the new files anyway :)
Regards,
Mariano.
:alright:
The problem is the parameter convention, you have declared C in the asm source code which is fine to link to the main.cpp but I will not link to the API. So I've changed that to stdcall and replaced your old C calling of mytime to a stdcall one and now it works.
func.asm:
.model flat,stdcall
include windows.inc
main.cpp:
extern "C" int __stdcall mytime(int,int,int,int);
I've attached the new files anyway :)
Regards,
Mariano.
:alright:
Thank you very much, Mariano. You helped me a lot. Nevetheless, I made a small fix also.
Instruction in func.asm
...
ret 0
gave a severe error during building. It should be just
...
ret
Thanks once again. I enclose a working code.
Regards,
Oleg
Instruction in func.asm
...
ret 0
gave a severe error during building. It should be just
...
ret
Thanks once again. I enclose a working code.
Regards,
Oleg
Yes, of course because there isn't any real address in the stack, anyway that isn't a code of my own, its your very first code ;)
It was working fine on my machine so I didn't see the rest of the code.
Regards,
Mariano.
:alright:
It was working fine on my machine so I didn't see the rest of the code.
Regards,
Mariano.
:alright: