error LNK2020: Unresolved token

L

lancer6238

Hi,

I'm using Microsoft .NET 2003, and I have the LNK2020 error when
building my program.

I have this in my code:

unsigned __int64 VarArray[256] = {0};

When I build the program, I get the error "error LNK2020: unresolved
token (0A000108) VarArray". Same error when declaring it as
"uint64_t", even though other variables (non-arrays) that are also
declared as "unsigned __int64" and "uint64_t" gave no error.

There is no error if I declare VarArray as "unsigned int" instead.

Eventually, I'm performing bitwise operations on VarArray.

What is wrong here?

Thank you.

Regards,
Rayne
 
D

David Resnick

Hi,

I'm using Microsoft .NET 2003, and I have the LNK2020 error when
building my program.

I have this in my code:

unsigned __int64 VarArray[256] = {0};

When I build the program, I get the error "error LNK2020: unresolved
token (0A000108) VarArray". Same error when declaring it as
"uint64_t", even though other variables (non-arrays) that are also
declared as "unsigned __int64" and "uint64_t" gave no error.

There is no error if I declare VarArray as "unsigned int" instead.

Eventually, I'm performing bitwise operations on VarArray.

What is wrong here?

Thank you.

Regards,
Rayne

Are the errors in other files than the one that includes the variable
definition? Perhaps you need an "extern" declaration of the global
variable in a header/in those other files?
 
V

Vincenzo Mercuri

Hi,

I'm using Microsoft .NET 2003, and I have the LNK2020 error when
building my program.

I have this in my code:

unsigned __int64 VarArray[256] = {0};
[...]

Hi,
a little research on google makes me think that you are mixing managed
and unmanaged code. Such "mixed mode application" won't be linked
against the "microsoft standard library". Read this thread, maybe it can
help you:

http://www.pcreview.co.uk/forums/thread-1433392.php

--
Non puoi insegnare qualcosa ad un uomo. You cannot teach a man anything.
Lo puoi solo aiutare -- Galileo Galilei -- You can only help him
a scoprirla dentro di sé. discover it in himself.

Vincenzo Mercuri
 
K

Keith Thompson

Hi,

I'm using Microsoft .NET 2003, and I have the LNK2020 error when
building my program.

I have this in my code:

unsigned __int64 VarArray[256] = {0};
[snip]

I'm not familiar with Microsoft extensions, but I'd be a bit surprised
if "unsigned __int64" were the right way to refer to a 64-bit unsigned
type. If __int64 is a typedef rather than a macro, that should be a
syntax error. (If it's a macro, it makes me wonder why the heck they
didn't make it at typedef.)

A bit of Googling indicates that there's something called __uint64.
I suggest using that rather than "unsigned __int64".
 
K

Keith Thompson

Vincenzo Mercuri said:
Keith Thompson wrote:
[...]
[...] I'd be a bit surprised
if "unsigned __int64" were the right way to refer to a 64-bit unsigned
type. If __int64 is a typedef rather than a macro, that should be a
syntax error. (If it's a macro, it makes me wonder why the heck they
didn't make it at typedef.)

A bit of Googling indicates that there's something called __uint64.
I suggest using that rather than "unsigned __int64".

Actually there exists something called Uint64 that is a "managed type",
but, according to the MSDN documentation, its C++/CLI equivalent is just
"unsigned __int64" or "unsigned long long":

http://msdn.microsoft.com/en-us/library/s3f49ktz(v=VS.80).aspx

http://msdn.microsoft.com/en-us/library/2e6a4at9(v=VS.71).aspx

I don't know if __uint64 exists actually, but "unsigned __int64" is
surely the right (Microsoft's) way to refer to it.

I think we should be surprised :)

I'm both surprised and dismayed.

According to the first of those web pages, int and long are both
32 bits (4 bytes).

No doubt __int32 is a macro that expands to "int", so "long __int32" is
a 32-bit type and "long long __int32" is a 64-bit type. Unless of
course __int32 expands to "long", so "long __int32" is a 64-bit type
and "long long __int32" is a syntax error.

Ugh.
 
F

Felix Palmen

* Vincenzo Mercuri said:
Uhm, I think that the "KISS" rule won't work at Microsoft.

If you ever read/wrote native win32 API code, you already know that. My
last 'wtf' moment was when I tried to modify an existing MSI file
through the windows installer api. I was indeed forced to prepare and
execute SQL queries to accomplish this.

Regards,
Felix
 
K

Keith Thompson

Kenneth Brody said:
On 10/19/2010 8:42 PM, Keith Thompson wrote:
[... Microsoft C ...]
No doubt __int32 is a macro that expands to "int",

"No doubt"? You're that certain?

Sorry, but Microsoft's C compiler has __int32 as a built-in type, along with
8, 16, 64, and 128-bit types.

http://msdn.microsoft.com/en-us/library/cc953fe1.aspx

Poor choice of words on my part. I was speculating. Apparently __int8,
__int16, __int32, and __int64 are implementation-defined keywords.
Well, "__int32" doesn't "expand" at all.

So I would speculate that "long __int32" or "long long __int32" would be
a syntax error.

BTW, that web page has a number of errors and omissions. There's no
mention of either "unsigned __int32" or "__uint32". It mentions
something called "longlong", described only as "Larger than an unsigned
long" (and discusses "long long" on the next line). It claims that

Objects of type int can be declared as signed int or unsigned
int. Signed int is a synonym for int.

but in fact something declared as unsigned int is not an object of type
int.

I hope their implementation is more coherent than their documentation.
Now, if other implementations define such types, they may define them
differently.

Certainly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top