|
The first one is no surprise as the compiler will pick the method of class on which you are calling the function. The second one is interesting, but it too is not a surprise to me as you have defined doo as virtual in the base class. Can you do a couple more tests:
1. Do not define doo as virtual in foo, and try this:
<br />
foo *f = new voo;<br />
f->doo(3,3); <br />
2. what if both the prototypes are in the same class, which one does the compiler pick:
<br />
class foo {<br />
void doo(int i, ...) {<br />
TRACE ("int i, ...");<br />
}<br />
void doo(int i, int j) {<br />
TRACE("int i, int j");<br />
} <br />
}<br />
foo f;<br />
f.doo(3, 3);<br />
|
|
|
|
|
1. foodoo
2. int i, int j
why do you think this would behave any differently than a function that doesn't have a vararg parameter ?
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
I was basically expecting an error thinking that C++ compiler would get confused in resolving the function call. It looks like the function with explicit arguments takes precedence over the function with varargs.
I wonder how this extends to function pointers...let me experiment this myself tomorrow.
|
|
|
|
|
I have recently tried incorporating someone's codes into my codes in visual c++. However their codes are in C. Anyway I have just added their .C and .H files into my project workspace and called one of their functions in my main program. I am unable to cmpile due to the error below:
regis.obj : error LNK2001: unresolved external symbol "struct Coordinates __cdecl findRotationMatrix(struct Coordinates)" (?findRotationMatrix@@YA?AUCoordinates@@U1@@Z)
Debug/regis.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
I understand that the compiler is looking for a library file but the problem is the codes i downloaded only came with the .C and .H file. If i am not wrong, the original codes were compiled successfuly in gcc. Is this a compatability problem?
|
|
|
|
|
findRotationMatrix is this declared in .h ?
|
|
|
|
|
It must be - he didn't encounter any compilation errors. Looks like he's missing a library.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
Looks like he's missing a library
Oops, you are very FAST
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Cillieacc0rd5o4 wrote:
findRotationMatrix is this declared in .h ?
Yeap,It's declared in .h File as there is no compiler error i.e. Function was found in Header file while compiling but since linker throw the error, it's seem that it enable to get DEFINATION of findRotationMatix function
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I believe your problem is that the function you're trying to use is in the .c file, and you're calling it from the .cpp file.
The compiler doesn't decorate names from the .c file, but it does decorate them from the .cpp. That why it appears to be calling:
glycemia wrote:
findRotationMatrix(struct Coordinates)" (?findRotationMatrix@@YA?AUCoordinates@@U1@@Z)
In the header file for the function (the header that goes with the .c file) you should place the following:
At the top of the header file
#if defined(__cplusplus)<br />
extern "C"<br />
{<br />
#endif<br />
Then put the rest of the header file in here.
and then at the bottom of the same header file:
#if defined(__cplusplus)<br />
}<br />
#endif<br />
That should resolve your problem.
Good luck.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Thank you so much for your help....your suggestion has solved my problem....
Does this mean I should convert the .c file into .cpp file in the future?
Thanks for all your help guys!!
|
|
|
|
|
Not necessarily. It is your choice, but you may run into other problems by converting it to .cpp.
If you're using mfc, you'll need to add the stdafx.h header, a wrapper to prevent multiple inclusions would be a good idea, etc.
Unless there's a compelling reason to change it to .cpp, then I'd just leave it like it is.
The software I work on (a suite of 38 applications and 18 dlls) has one module that is shared with a unix-based hardware component, and that has to be in c, so we just have the one module in c.
Glad I could be of help.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
but did you think to #include the header whenever you imported them into your project ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
MSDN Sux !!!
Filter wont work cant find nada.
here i am again. Questions is for a loop or loop for fo some sort.
// I want to set all relays to 0(fl_set and 1 is on)
// By all relays i mean 1-25 relays
// So all 1-25 relays need to have 0
// was thinking of a loop to do this
EXP_USHORT Reset_All_Relais(int relay, int fl_set)
{
for relay (0 To 25)
{
return ScoUniSetRelay(relay,0);
// Simple be
return ScoUniSetRelay(1,0);
return ScoUniSetRelay(2,0);
return ScoUniSetRelay(3,0);
return ScoUniSetRelay(4,0);
return ScoUniSetRelay(5,0);
// etc etc till 25 LOL
}
}
cant find nothing in MSDN maybe it was another statment. Any idea guys what else can be used ?
|
|
|
|
|
Is this what you're trying to do?
for (int nRelay=1; (nRelay <= 25); nRelay++)
ScoUniSetRelay (nRelay, 0);
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ahhhh yeah i think,....
What is this statement called in C++ For Loop ?
|
|
|
|
|
|
Can it be used like this.
EXP_USHORT Reset_All_Relais(void)
{
for (int nRelay=1; (nRelay <= 25); nRelay++)
{
return ScoUniSetRelay (nRelay, 0);
}
}
And what does my compiler means specificly with:
arning C4715: 'Reset_All_Relais' : not all control paths return a value
Linking...
|
|
|
|
|
no, what should the function Reset_All_Relais returns ?
now, the first time the function ScoUniSetRelay is called it will return the Reset_All_Relais function.
remove the return in the loop and place it at the end.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
its suppose to give this back
return ScoUniSetRelay(relay,0);// for each relay the next
return ScoUniSetRelay(relay,0);// Number untill 25 including 25
return ScoUniSetRelay(relay,0);//
return ScoUniSetRelay(relay,0);
return ScoUniSetRelay(relay,0);
return ScoUniSetRelay(relay,0);
thats y i wanted return not at the end
PS: Suppose to give all tha back for the robo to set all the Relay back to off. ScoUniSetRelay(relay,0) 0=off relay for which one.
|
|
|
|
|
if you do that it will return on the first one, and never do the other ones.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
EXP_USHORT Reset_All_Relais(void)
{
for ( int relay = 0 ; relay <= 25; relay ++ )
ScoUniSetRelay(relay, 0);
}
return
}
Something like this ?
B\c that is not working for me never used Loop n that stuff before so something is missing i think. ; gives me another error
EDIT !!!!!
PS: I dont need any return crap I can make the proto type run with out Return to check if it was or not just need to to make that damn thing do her stuff.
THANKS ALOT !!!!
|
|
|
|
|
i think you'd better take a piece of time to learn about at least C, or C++ if needed, because you really lacks in every basic knowledges on the language...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I wont argue with you but i do LOL.
I was assigned to this knowing be able to write it in java. But all the application adn control programs can only understand C++ or Pascal and some otehr machine language.
Truthfully i think i am getting the hang onf it though after the explaination of loop for.
=) !!!
My 8 page program is done and later ima go test it.
Worst thing that can happen the Robo pokes everything to oblivion hahah !!!!
Thanks guys
|
|
|
|
|
Please don't misunderstand me when I say this, but you should have a firm grasp of the basic C/C++ control structures and the return statement before embarking on your project.
This is what you need to do:
void Reset_All_Relays()
{
for (int nRelay=1; (nRelay <= 25); nRelay++) {
ScoUniSetRelay (nRelay, 0);
}
}
If ScoUniSetRelay() returns a status, you need to decide how Reset_All_Relays() should behave if it encounters an error - i.e. should it interrupt the loop, ignore the error, continue with the loop but return the failure notification to the caller, something else...?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Yeah Took me awhile to get the grasps for what those things are. USHORT needs return value Void not etc etc Long and so =)
Now i can dig in C++ Not so much diff than java basics are same. just diff looks confused the hell outta me !!!
beside writing 8 page code and this is like 1 and half week on C++ for first time aint that bad huh ??? Maybe i am slow.
|
|
|
|