Click here to Skip to main content
15,886,110 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Linked List Cleanup Pin
Greg Utas24-Mar-22 7:19
professionalGreg Utas24-Mar-22 7:19 
GeneralRe: Linked List Cleanup Pin
Calin Negru24-Mar-22 6:04
Calin Negru24-Mar-22 6:04 
GeneralRe: Linked List Cleanup Pin
Greg Utas24-Mar-22 6:13
professionalGreg Utas24-Mar-22 6:13 
GeneralRe: Linked List Cleanup Pin
k505424-Mar-22 7:09
mvek505424-Mar-22 7:09 
GeneralRe: Linked List Cleanup Pin
Calin Negru24-Mar-22 21:12
Calin Negru24-Mar-22 21:12 
GeneralMFC MDI Change tab styles after Addview is completed via Property Sheet Pin
kittmaster21-Mar-22 10:55
kittmaster21-Mar-22 10:55 
QuestionMessage Closed Pin
21-Mar-22 10:28
Member 1496877121-Mar-22 10:28 
AnswerRe: how do I verify - "all the ducks in the row "? Pin
k505421-Mar-22 11:09
mvek505421-Mar-22 11:09 
I'm net entirely clear on what you're trying to do.

Normally, a library that is expected to be used by a developer is supplied with a header file that describes the contents of the library, that is #included in the source file of user created software. That's what stdio.h or iostream do for you. If at all possible, you should look for the developer tools for your library and use the supplied headier.

Alternatively - and this is only as a last resort for the well-informed and foolhardy, there's no reason you can't declare the function in your own source code. But, you really have to know what the function signature is. If you have a mismatch, then you're almost certainly going to invoke Undefined Behavior, and then all bets about the validity of anything your program produces is suspect.

So for example, we know that the signature for a cosine function in the c standard library is double cos(double x;. Now normally we would write
C
#include <math.h>
// ....
   double val = cos(2.5);
// ...
But it's perfectly valid to write
C
double cos(double x);
// ...
    double val = cos(2.5);
// ...
But as I state above, you need to be sure that you've got the right signature for your function. If for example we were to write
C
double cos(int x);  // Wrong! cos() takes a double, not an int
// ...
    double val = cos(2.5)
/ ... 
Then the compiler will convert the 2.5 to an integer (e.g. a 4 byte value containing the value 0x02), and then pass that to the math library cos() function. On the library side, the code is expecting a double (e.g an 8 byte value in IEEE floating point format), so it will dutifully use the top 8 bytes of the stack for the value to calculate the cosine for. As you can see, we've only put 4 bytes on the stack in our call, and so half the data its using to calculate is, in essence, random data. Clearly, in this case we can't rely on what value cos() returns to us.

This is not the same as passing an int to cos() that has been properly declared. In that case, the compiler knows that the cos() function is expecting a double as its argument, so it provides a conversion from int to double at compile time.
Keep Calm and Carry On

GeneralMessage Closed Pin
21-Mar-22 15:28
Member 1496877121-Mar-22 15:28 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
Richard MacCutchan21-Mar-22 22:38
mveRichard MacCutchan21-Mar-22 22:38 
GeneralMessage Closed Pin
24-Mar-22 10:36
Member 1496877124-Mar-22 10:36 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
k505424-Mar-22 11:06
mvek505424-Mar-22 11:06 
GeneralMessage Closed Pin
24-Mar-22 13:25
Member 1496877124-Mar-22 13:25 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
Richard MacCutchan24-Mar-22 21:49
mveRichard MacCutchan24-Mar-22 21:49 
GeneralMessage Closed Pin
25-Mar-22 10:17
Member 1496877125-Mar-22 10:17 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
k505425-Mar-22 11:26
mvek505425-Mar-22 11:26 
GeneralMessage Closed Pin
25-Mar-22 14:25
Member 1496877125-Mar-22 14:25 
GeneralMessage Closed Pin
25-Mar-22 16:33
Member 1496877125-Mar-22 16:33 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
k505428-Mar-22 5:26
mvek505428-Mar-22 5:26 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
Richard MacCutchan25-Mar-22 22:53
mveRichard MacCutchan25-Mar-22 22:53 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
trønderen25-Mar-22 12:58
trønderen25-Mar-22 12:58 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
k505426-Mar-22 5:07
mvek505426-Mar-22 5:07 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
Richard MacCutchan25-Mar-22 22:51
mveRichard MacCutchan25-Mar-22 22:51 
GeneralMessage Closed Pin
28-Mar-22 14:44
Member 1496877128-Mar-22 14:44 
GeneralMessage Closed Pin
29-Mar-22 6:05
Member 1496877129-Mar-22 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.