code compiles fine... but has build error

Started by
3 comments, last by Zahlman 14 years, 11 months ago
error LNK2019: unresolved external symbol "void __cdecl sortDescendName(struct Contestant * const,double)" (?sortDescendName@@YAXQAUContestant@@N@Z) referenced in function _main I don't get what the error here means.. here is the declaration of the function and the function call in case I screwed something up there. declaration: void sortDescendName(Contestant[], double); function call: sortDescendName(cont, numbcont); thanks for the help :]
Advertisement
This error means that you are calling a function, but you never actually provided any code for that function to the compiler. If this is a function you meant to write yourself, double-check that you have in fact written it and that it is named the same thing as in your function prototype. (Also ensure there are the same number of parameters and that the parameters are of the same types.)

If this function is from a library, double check your project settings and ensure that the correct .lib file is referenced by the linker.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

i figured it out
i had declared numbcont as an int
and in teh fuction definition it was a double
not sure why the compiler didn't pick it up
thanks tho!
Function definition is declaration in most cases. So if you declare a function which takes a double yet define it to take an int, then the compiler will look at your definition and think you are trying to define an overloaded function that takes an int. So then it will say (when linking) that there is no definition for the double one.
[Window Detective] - Windows UI spy utility for programmers
Quote:Original post by neipo13
i figured it out
i had declared numbcont as an int
and in teh fuction definition it was a double
not sure why the compiler didn't pick it up
thanks tho!


It doesn't matter if that's how you call the function, because int is implicitly converted to double. It does matter if that's how you define the function, because your definition must match the declaration (otherwise it's defining something else).

Usually when you get an error like this, it's because you're not #including the header that declares the function, or don't have the .cpp file that defines it in the project.

This topic is closed to new replies.

Advertisement