|
|
<br />
__cdecl is the default calling convention for C and C++ programs. The advantage of this calling convetion is that it allows functions with a variable number of arguments to be used. The disadvantage is that it creates larger executables. <br />
__stdcall is used to call Win32 API functions. It does not allow functions to have a variable number of arguments. <br />
__fastcall attempts to put arguments in registers, rather than on the stack, thus making function calls faster. <br />
Thiscall calling convention is the default calling convention used by C++ member functions that do not use variable arguments.
What's "variable number of arguments" ?? means Overloaded functions?
And about _fastcall, if it's going to be faster, why not use it for every function we create? can you tell me about , where a particular convention must be used strictly. (yes, I've not gone through the article fully, but if you can explain please do)
|
|
|
|
|
Variable number of arguments:
Think printf, where you can pass one or more arguments, and the format control string determines how many arguments there are (hopefully correctly!).
fastcall wouldn't be suitable for functions that take more than two or three arguments, and in some cases might be slower; there aren't an unlimited number of registers on a 32 bit processor.
Generally, you don't need to specify the calling convention, but in some cases, you do, simply to ensure that the function has the one expected. Good examples are the functions you pass to things like qsort() and _beginthreadex().
Steve S
Developer for hire
|
|
|
|
|
thanks
NULL
|
|
|
|
|
Meat Loaf wrote: What's "variable number of arguments" ?? means Overloaded functions?
You must have used printf , sprintf , fprintf , scanf , sscanf etc. They all take variable number of arguments. Take a look at va_start , va_end , va_arg .
__cdecl calling convention specifies that the caller has to clean up the stack leading to larger executable size. Hence permitting the use of variable number of arguments.
Meat Loaf wrote: __stdcall is used to call Win32 API functions. It does not allow functions to have a variable number of arguments.
Yeah true. For eg: WINAPI , PASCAL are #define d to be __stdcall . This is windows specific. This means the callee has to clean up the stack just before the callee returns hense variable number of arguments cannot be used here.
Meat Loaf wrote: __fastcall attempts to put arguments in registers, rather than on the stack, thus making function calls faster.
Meat Loaf wrote: And about _fastcall, if it's going to be faster, why not use it for every function we create?
Because we have limited number of registers.
Meat Loaf wrote: can you tell me about , where a particular convention must be used strictly.
You have to decide. Where what should be used. __stdcall doesn't permit variable number of arguments hence which calling convention will you use?
Meat Loaf wrote: Thiscall calling convention is the default calling convention used by C++ member functions that do not use variable arguments.
This calling convention allows class member functions to have the implicit this argument.
Meat Loaf wrote: (yes, I've not gone through the article fully
Then please do.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Thanks for ur reply.
|
|
|
|
|
|
Hi All,
Sorry i am back again.
Steve i am getting below errors can please tell me what is cause.
--------------------Errors--------------------
--------------------Configuration: DesktopSearch - Win32 Debug--------------------
Compiling...
SearchDlg.cpp
SearchDlg.cpp(641) : error C2065: 'textLen' : undeclared identifier
SearchDlg.cpp(642) : error C2664: 'SetSelectionCharFormat' : cannot convert parameter 1 from 'struct _charformat *' to 'struct _charformat &'
A reference that is not to 'const' cannot be bound to a non-lvalue
Error executing cl.exe.
2 error(s), 0 warning(s)
-----------Code--------------------------
void CSearchDlg::HilightWords(char* word)
{
CHARFORMAT cf;
memset(&cf, 0, sizeof(CHARFORMAT));
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_BOLD;
cf.dwEffects = CFE_BOLD;
FINDTEXTEX findText;
int foundCount = 0;
int foundPos = 0;
int wordLen = lstrlen(word);
findText.chrg.cpMin = 0;
findText.chrg.cpMax = -1;
findText.lpstrText = word;
foundPos = m_FCONT.FindText(FR_WHOLEWORD, &findText);
while (foundPos != -1)
{
m_FCONT.SetSel(foundPos, foundPos + textLen); //Error 1
m_FCONT.SetSelectionCharFormat(&cf); //Error 2
findText.chrg.cpMin = foundPos + textLen;
foundPos = m_FCONT.FindText(FR_WHOLEWORD, &findText);
}
}
void CSearchDlg::OnDblclkSout()
{ -----------
-------------------------
----------------------------------------
FILE *fp = fopen(str,"r");
if (fp)
{
// goto the end of file
fseek(fp, 0L, SEEK_END);
// get the length of the file
long fileLen = ftell(fp);
// go back to the start of the file
rewind(fp);
// allocate buffer for file contents
char* text = new char[fileLen + 1];
// read the file into the buffer
fread(text, 1, fileLen, fp);
// null terminate the string
text[fileLen] = 0;
// set the window text
m_FCONT.SetWindowText(text);
delete [] text;
fclose(fp);
}
else
{
MessageBox("Select only file name to open.",MB_OK | MB_ICONINFORMATION);
return;
}
HilightWords(word);
}
Regards,
Vinay Charan.
|
|
|
|
|
what is it 'textLen' and where is line that has error struct _charformat
whitesky
|
|
|
|
|
Hi whiteSky,,
Error lines are
m_FCONT.SetSel(foundPos, foundPos + textLen); //Error 1
m_FCONT.SetSelectionCharFormat(&cf); //Error 2
Regards,
Vinay Charan.
|
|
|
|
|
m_FCONT.SetSel(longnStart,longnEnd)
m_FCONT.SetSel(foundPos, foundPos + textLen); //Error 1
m_FCONT.SetSelectionCharFormat(cf); //Error 2
whitesky
|
|
|
|
|
Alrighty, holy mother of fritos and spicy bean dip (Is that kid sister friendly enough?) I guess I took this on as a personal crusade and I like to finish what I start when I can.
Error 1:
Just change textLen to wordLen (it was a typo in my code) I didn't know you didn't know C++ (I guess I should've inferred that, but live and learn...)
Error 2 change to:
m_FCONT.SetSelectionCharFormat(cf);
And I'm done, learn how to problem solve or you will be done too. (I mean, that if you can't look something up with google, then you're laaaame). I know you're trying to get your homework done, but come on dude, try, try!!!!
Last modified: Friday, May 26, 2006 12:56:10 AM --
|
|
|
|
|
Hi Steve Echols,
Thanks for helping....Now its working...
Since my semester is of 4 months I did not get time to attend VC++ classes outside, I just started learning on my own with help of Code Project and with help of masters like u and started working on my academic project.
Since VC++ different from C++ I am finding it more difficult to understand the syntax and procedure…
Can u please also tell how to increase the font(size) of the selected word,it will be helpfull if u can provide some links.
Regards,
Vinay Charan.
|
|
|
|
|
|
Thanks Steve...
I will do the research on CHARFORMAT ...
Thanks a lot
Regards,
Vinay Charan.
|
|
|
|
|
|
Nibu thomas wrote: May be you can write an article on this subject. A 5.
The sad thing is I've never actually used a RichEdit control (in practice). The great thing about helping people out is that you also learn in the process (VinayCool cover your ears!) I've learned alot about RichEdit stuff (Thank you VinayCool!)
|
|
|
|
|
Steve Echols wrote: The great thing about helping people out is that you also learn in the process (VinayCool cover your ears!) I've learned alot about RichEdit stuff (Thank you VinayCool!)
Very true. Good job.
But sometimes these questions get to you. Some understand some don't.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Spanks!
Nibu thomas wrote: But sometimes these questions get to you. Some understand some don't.
That's the cool thing about CP, there are some who know "flat out", and some who don't have a clue but will research problems that interest them just for the piece of mind!
|
|
|
|
|
Good idea
whitesky
|
|
|
|
|
Cool
Regards,
Vinay Charan.
|
|
|
|
|
Hi All,
This is not a technical doubt. but it is related to C++.
one of my friend is searching for an International Certification in CPP (like Java). I donno why it is needed but she is sticking on that.
Pls give some suggestions.
SaRath
|
|
|
|
|
|
Is the brainbench certification is an accepted one ???
Still i am wondering that why the Microsoft ppl stopped the Certification Exam in C++ aka VC++..
Loka Samastha Sukhino Bhavanthu..!!!
( May all beings be happy and free )
|
|
|
|
|
Am not sure about the acceptability of brainbench.
I think Microsoft just wanted to promote .NET certification.
|
|
|
|