c2491 error

  • Thread starter Thread starter mschmitz
  • Start date Start date
M

mschmitz

Im trying to update some code from VC 6.0 to .net 03.

While building i get the c2491 error (definition of dllimport function
not allowed), which i have seen posted on here but havent found a
solution to.

Does this mean i can only delcare a dllimport function and NEVER define
it? What is the solution, or where can i find a link to a previously
post.
Thanks,
mschmitz
 
Hello !

Yes, it means precisely that. Imported functions can only have a declaration
such as follows:

__declspec(dllimport) int ImportedFunc(int nParam1, int nParam2);

This will create an entry into the module's import table, and tries to find
an exported ImportedFunc from any and all other modules this one is linked
with. If it is not found, you will receive a linker error "Unresolved
symbol". You cannot define an imported function. That's the way it is
supposed to work, and there's no changing it.

However, the immediate question that rises to my mind is why on earth would
you want to define an imported function ?
Also, it's impossible to provide a solution to you, because you've not
stated a problem either. Being unable to define an imported function is not
a problem; it's a feature of the language, the way it's supposed to work.

-Antti Keskinen
 
Back
Top