0

OK so I'm using Visual Studio Community 2019 with MASM enabled and I'm trying to declare a variable in my ASM file that is defined outside of the .ASM file but in the same project. How can I do this ?

I've tried the following:

EXTERN MyVar:ULONG64

but Visual Studio gives me the following compile error:

Error   A2006   undefined symbol : ULONG64  TestDrv C:\Users\XFL\Documents\Visual Studio 2019\Projects\XFL\TestDrv\TestDrv\SwapSrc.asm  9
  • ULONG64 isn't a native type. Do you have a typedef for it or an include that defines it? Does `unsigned long long` work any better? – David Wohlferd Apr 12 '22 at 23:34
  • @DavidWohlferd thank you. My apologies for not being clear but I'm declaring the above statement in a ASM file that is part of the VS project. I did try unsigned long long but it gave me a different error Error A2008 syntax error : long TestDrv C:\Users\XFL\Documents\Visual Studio 2019\Projects\XFL\TestDrv\TestDrv\HookSwapSrc.asm 9 – user121309 Apr 12 '22 at 23:46
  • So how about `QWORD`? – David Wohlferd Apr 12 '22 at 23:55
  • @DavidWohlferd thank you. I cannot declare this variable as type QWORD in my .cpp file since I cannot use the QWORD identifier in x64 bit mode the compiler gives me an error. Error (active) E0020 identifier "QWORD" is undefined TestDrv C:\Users\XFL\Documents\Visual Studio 2019\Projects\XFL\TestDrv\TestDrv\HookSprw.cpp 22 – user121309 Apr 13 '22 at 00:38
  • Does `unsigned long long` work any better? – David Wohlferd Apr 13 '22 at 00:41
  • @DavidWohlferd thank you. I did try "unsigned long long" but I still get an error Error A2008 syntax error : long – user121309 Apr 13 '22 at 12:49
  • https://learn.microsoft.com/en-us/cpp/assembler/masm/qword?view=msvc-170 – Hans Passant Jun 22 '23 at 09:17

1 Answers1

0

C and assembler are very different languages and everything is spelled differently. Assembler names all 64 bit types (including floating point doubles) QWORD, the C language and Windows headers use other names such as __int64, long long, etc.

Similarly assembler writes hexadecimal 64 bit numbers as 0123456789ABCDEFh while the C language writes it 0x0123456789ABCDEFui64 etc. etc.

jb_dk
  • 117
  • 6