The Code + Errors
I tried to use the extern keyword but that didn't work. All I want is a global function I can call that connects to mysql for me. Any idea's on how to fix the above?
The Code + Errors
I tried to use the extern keyword but that didn't work. All I want is a global function I can call that connects to mysql for me. Any idea's on how to fix the above?
It doesn't sound like a proper use of extern... Though I didn't even read the code.
Code in header file bad. That is what the complaints are about. Pick a .cpp file to put it in.
charset should be extern in the header, and defined in whatever .cpp file is appropriate (but only once!)
And indeed you don't use the variable mysql in your find thing, so ... yeah. (It's not the same one as in your .h file.)
The code listed is before I tried the extern. I was hoping some one could point me in the right direction on if the extern would be the best option or if there is another solution.
Updated Code
I updated it with trying to use extern. I managed to get it "working" at one point but my program crashed when accessing mysql but not sure what I had then.
Functions aren't ever extern. The dlgcustomer.cpp file you posted doesn't even have 135 lines in it, so who knows what's going on there.
So do you have a suggestion on how to get this working?
I know, I cut out some of the wxWidgets code to shorten it down. I just wanted the errors to be seen.
What do you mean by this? From what I have found from google you can do extern void myFunc() just fine.Functions aren't ever extern.
Well you can put the word "extern" in front of a prototype, yes. Since it already is a prototype, you're not adding anything. I wouldn't say that functions have linkage like objects do.
Is it a compile-time or link-time error? It looks like everything's #included correctly. The point about line 135 is that the function name is used elsewhere in the function, unless you only are showing us line 135.
I want to say link - at home at the moment so can't double check.
So, I have to backtrack a little bit; functions have linkage too; the standard says this:
So there you go -- extern by default.Originally Posted by ISO C 6.2.2
Anyway, link seems likely. Check if you even have a dbconnect.o; if not, it's definitely not in your project; if so, either somehow it's not getting linked or it's not in your project but you compiled it separately at some point.
i'm 99.9999% it's part of the project - I'll look for the dbconnect.o
The way it was when I posted the updated code it was a compiler error not linker
Aight, now that I'm back at work I figured it out. Thanks a ton. It was a linker error (had something commented out that I didn't notice so it looked like a compiler error) The .cpp wasn't being compiled or linked but now that it is it is working like a charm!
Function prototypes default to extern, but you can use static to limit their scope.