Undefined symbol errors mean the linker can't find an actual address to correspond to a name you've used. If this isn't due to simply leaving a necessary .lib out of the build, then it is usually due to mismatched calling conventions. For example I see that the compiler is mangling the function name digit. If that name is really in a C library and not mangled, then you'd get this error. You can prevent name mangling by declaring it as extern "C".
This is what happened when I placed a "Extern C;" in the variables section
Error on line 9 (Extern C; )
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\maulin\my documents\visual studio 2008\projects\time\time\time.cpp 15 Time
If I get rid of the 'int assumed' error, do I need to replace all digit with anything?
1) Your function prototype is inside main(), which makes the compiler thing you're trying to call function digit, not define it. If you want to define function digit, put the prototype outside main (above main in the file), and call the function. Something like this:
// includes
// fcn prototype
void digits(int minutes);
using namespace std;
int main() { // etc ...
// second switch statement
digits(minutes);
// rest of main
} // curly brace to close main
// Now define digits down here
void digits(int minutes) {
// code for digits goes here
}
2) The extern C isn't required, and you should get rid of it. As an aside, you'd have to put it around the function prototype, but you don't need it anyway.
I really wish they would fix the attach code "feature"... or at least remove the option to do it so it forces people to keep it in their OP... at least that way we only have to worry about the formatting engine mangling array indexes!
I'll bring it up in the mod area and see what they say, but we're a small corner of a really big site, as you guys all know, so don't hold your breath.
You're getting warmer BustaBust --
You need to close main with a } before starting another function, and you need to start a function with { not ;
Do the following:
On line 75, add a function call to digits. The exact syntax is: digits(minutes);
On line 76, close main. The exact syntax is: }
Line 79 is not supposed to be a prototype -- it is supposed to be a definition. Make it a definition by changing the ; to a {
(note that the closing } for this function is already there on 112, currently closing main.)
Edit: I'm lecturing about brace matching, and yet I somehow forget to close a parenthesis
When you are trying to use 'hours' in your code the compiler is complaining that it doesn't know what 'hours' is. Usually because you didn't declare that variable in the same scope that you are trying to use it.
So after looking at your code again, I have no idea what you want digits() to do. I didn't notice the calls to digit(), e.g. digits(minutes-20) on (original) line 84. But I have a new set of deltas for you, starting with the original file:
1) remove the (redundant) function prototype of digits from line 79
-- all code should now be in 'main', and you should be back to your original linker error (if not, make it so)
2) Add the following to the end of your file
void digits(int minutes) {
// Whatever you want digits to do, here
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.