|
I must say "thnx" to the writer of article "Calling Conventions Demysified".
It is such a good article, i mean im a student n i feel it is must for every c programmer.
But im confused with what was written in first few lines :
"the value is returned in EAX register."
I mean no problem with basic types but how this statement fits fine for structures like:
struct abc
{
int x;
float y;
};
struct abc fun(void)
{
struct abc x;
x.x=0;
x.y=1;
return x;
}
Spread wat u Know!
|
|
|
|
|
Returning things that don't fit into a register have a special rule in all calling conventions that use a register to return values. One possible solution some calling conventions use is that the caller reserves the memory for the return value and passes a pointer to it to the called function as a hidden parameter.
So your example would be compiled like:
struct abc
{
int x;
float y;
};
void fun(struct abc *result)
{
struct abc x;
x.x=0;
x.y=1;
*result = x;
}
An optimizing compiler might assign directly to result->x and result->y.
|
|
|
|
|
help me pls...i m using c++ to do it..
hope can help me bcos the due date is near and i still cannot find any solution on its...
i only can display bitmap but when display in other image format...it cant load and display..
|
|
|
|
|
|
i have try this b4....but the problem is "Before use the CEDraw Library, you must copy some support file in you system"
a. Copy the dll to you WinCE system directory
1.If using in emulation mode, copy two of the dll in …\CEGraph\DLL\X86Em directory ( gx.dll & cegl.dll) to the emulation windows system directory, always in the D:\Windows CE Tools\wce300\MS Pocket PC\emulation\palm300\windows directoty, then copy the file Hzk16 in the …\CEGraph\Res directory to the WinCE Root directory, always in D:\Windows CE Tools\wce300\MS Pocket PC\emulation\palm300
2.if using an Arm system, copy the two DLLs in …\CEGraph\DLL\Arm ( gx.dll & cegl.dll) to the Pocket PC windows system directory. Then copy the file HZK16 to the System Root directory.
i found that i don hav ethe gx.dll and cgl.dll in my d drive or cdrive...so how should do to solve that kind of problem??????????
|
|
|
|
|
Both files (gx.dll & cegl.dll) are in the archive of the article (here), in the CEGraph/DLL subfolder. Find them and follow the article.
-------------------------
Don't worry, be happy )
|
|
|
|
|
but why the path that provided is not same with mine1??it say copy both file into D:\Windows CE Tools\wce300\MS Pocket PC\emulation\palm300\windows directoty...but in fact,i cannot find the exact path either in c drive or d drive....mine1 is D:\Windows CE Tools\eVC4..
|
|
|
|
|
The only thing I can recommend - try. Obviously, the author of the article gave HIS paths, that can differ among users...
-------------------------
Don't worry, be happy )
|
|
|
|
|
after i finish copy the .dll file into specific directory...
i wil go to next step which set up the directory..i have found dificuties on its..
where shoud i start set the including and lib directory??
when i open the project setting, i found that there may not have --->Link--->Object ???
hope can giv me a perfect solution on its...;P
|
|
|
|
|
I used Visual Memory Leak in my code and it has reported memory leak from files having this code. Can anyone give information as to whether these codes can lead to memory leak or not
************************************
case 1
************************************
sub_code = (char *) calloc(5,sizeof(char));
if(f_decimal_value !=0 )
{
free(sub_code);
sub_code = (char *) calloc(3,sizeof(char));
//additional code here
free(sub_code);
}
else
{
free(sub_code);
sub_code = (char *) calloc(3,sizeof(char));
//additional code here
free(sub_code);
}
*********************************************
case 2
**********************************************
sub_code = (char *)calloc(3,sizeof(char));
char2str(2,sub_code)
if(strcmp(sub_code,"00") == 0)
{
free(sub_code);
//additional code here
}
else if(strcmp(sub_code,"01") == 0)
{
free(sub_code);
//additional code here
}
else if(strcmp(sub_code,"10") == 0)
{
free(sub_code);
//additional code here
}
else if (strcmp(sub_code,"11") == 0)
{
free(sub_code);
//additional code here
}
|
|
|
|
|
The bits you leave out are the bits we need to see!
For example, in the first example the code that's missing and commented with "//additional code here" could cause a leak if:
- It returns.
- It stomps on the pointer value in sub_code without seeing that it's freed.
- It throws an exception.
Steve
|
|
|
|
|
Case 2 could lead to a leak because your "else if" chain has no final else clause. If none of the conditions apply, sub_code will never be freed.
You could just add at the end
else
free(sub_code);
and that would take care of it.
|
|
|
|
|
Can anyone help me to create a tree view after parsing a file
ie from the file dialog when we open a file, it should be loaded in to a tree structure. Also i want to save the items in the tree in to a file.
syam.
|
|
|
|
|
Do you want to pasre a xml file and what does mean "create a tree view after parsing a file" ?
|
|
|
|
|
To parse the file and with the items obtained build the tree structure..........
|
|
|
|
|
Hi all, am writing a program in embedded VC++...
am new to programming so i need some help with a little thing..
i have a form that the user will input a hex value (memory address) and my program will copy this value to a pointer.. but it just isn't working. here is my code
DWORD *pDUMMY;
TCHAR sztTmp[10];
GetDlgItemText(hwndDlg, IDC_EDT_NAME,sztTmp, 10);
pDUMMY=(DWORD *)(sztTmp); //this line needs some editing
example: user enters 0x8fff42a2
should equal pDUMMY = (DWORD *) (0x8fff42a2)
sorry for the stupid question.. i'm helpless...
|
|
|
|
|
pDUMMY = _tcstoul( sztTmp, NULL, 0 );
passing the 0 means that if the string starts with 0x then it's assumed to be hex, if it starts with 0 and not an x then it's assumed to be octal, and otherwise it's assumed to be a decimal value so it's rather flexible.
you can pass 16 instead if you always assume the value is hexadecimal.
|
|
|
|
|
Rick York wrote: pDUMMY = _tcstoul( sztTmp, NULL, 0 );
actually you have to do
*pDUMMY = _tcstoul( sztTmp, NULL, 0 );
note the pointer dereference operator.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
It works.... haha!... thank you guys, you saved me!!!
|
|
|
|
|
can any one give me the difference between lib and dll in detail?
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
Static library is a lib, while a dynamic library is a DLL.
The problem with libs is that they limit the user to a specific compiler. Where as DLL are more flexible. When using libs a programmer never has to be in a worry of that .lib file being present on the user's machine while dll's impose such dependencies.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
.lib files help up match up the actuall library(.DLL) It's called implicit linking. .lib files get created when you export functions using .DEF file. Once done you can include this .lib file in your application and start using the DLL as if it's available in a .cpp file. (implementation). The .lib file takes care of mathing the call to the dll.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
hi,
Anybody knows how to add a string in front of another string and also at the back of the string. Here is the code that generate unhandled exception and access violation error.
Thanks for any reply.
{ char myfilename[15];
char Pathn[20]="";
strcat(Pathn,"c:/My File/");
int coord;
fSrc>>myfilename;
for(int l=0;l<6;l++)
{
testIC[l]=ICname[l];
}
strcat( ICname, " output.txt" );
strcat(Pathn,ICname);
outputfile=("%s",Pathn);}
|
|
|
|
|
It's obvious that Pathn is not large enough.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Don't use raw char arrays without a compelling reason to do so. Use std::string instead.
Steve
|
|
|
|