|
Hi,
I have a function for comaring.
int DataPeakCompareFunc(const void *el1, const void *el2)
{
const DataPeak *peak1 = reinterpret_cast(el1);
const DataPeak *peak2 = reinterpret_cast(el2);
if (peak1->position < peak2->position)
{
return -1;
}
else if (peak2->position < peak1->position)
{
return 1;
}
return 0;
}
this is my qsort function
int (FConvert::OConvevw::*pt2Function) (const void*, const void*) = NULL;
pt2Function = &FConvert::OConvevw::DataPeakCompareFunc;
qsort((void*)pScan, num_readings, sizeof(DataPeak),pt2Function);
But i am getting this error
Error 206 error C2665: 'qsort' : none of the 2 overloads could convert all the argument types d:\cougar_io_development\cougar\core\libraries\cplusplus\dlls\fconvert\OConvevw.h 789
both are residing in oconvevw.h file only.
What to do?
Thanks in advance.
Regards, Eswari
|
|
|
|
|
may be this is the wrong forum to ask.. But i could not see any C++ category.
That's why i posted here
|
|
|
|
|
At least one of the parameters you are passing to qsort() is the wrong type.
I suspect the last parameter. The compare function should have the following prototype:
int (__cdecl *compare )(const void *, const void *)
but you are passing a
int (FConvert::OConvevw::*compare)(const void*, const void*)
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Is DataPeakCompareFunc() a static or non-member function?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
member function defined in the same class where qsort is being called
|
|
|
|
|
subramanyeswari wrote: member function defined in the same class where qsort is being called
Thus it needs to be a static member.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Don't use qsort ; it's outdated. Use STL.
e.g.
inline bool operator<(const DataPeak &l, const DataPeak &r)
{
return l.position < r.position;
}
std::sort(container.begin(), container.end());
std::sort is in <algorithm>
Steve
|
|
|
|
|
Hello,
I have an int array
int a[10].
The array will have only 3 to 4 values in the it.
so how do I check for NULL values in the array
because I cannot check
a[i]!=0 since I want 0 as a value
Thanks
Prithaa
|
|
|
|
|
Not sure I understand your problem, but the simplest thing to do is to initialize your array to zeros before you even use it. But why use an array of size 10 when a size of 4 would suit your needs??
John P.
|
|
|
|
|
ints are just integer values. If you need to indicate an uninitialized int then you'll need to
set aside one number to represent an invalid value.
What are the valid range of values for your arry members? Pick a number outside that range
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Alternatively, you can use int pointers instead of array. This way you can check if the value is NULL
|
|
|
|
|
or an array of int pointers.
|
|
|
|
|
To make sure, use an array of int pointer pointers, each member pointing to the corresponding
member in the int pointer array, whose members point to the actual ints!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Sure that'll work.
Another alternative - make a "smart int" class, wrapping an int with some flag indicating
its initialized status Then you wouldn't need the added indirection of a pointer.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
A dynamic array as std::vector<int> doesn't fit your needs?
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.
|
|
|
|
|
You need to use a different value and initialize the array to that. Since you want to allow 0 to be placed in the array then use -1 to initialize it. That is fill the array with -1 and check for that. If that is not an option, and there is no other value you can use, then you have a real problem.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi Guys,
I am developing an Encrypted VoIP application for PocketPC(Windows Mobile 5.0). The VoIP part is ready and I am looking for a AES encryption algorithm to encrypt/decrypt my RTP Payload/Packets for PocketPC Windows Mobile5.0.
Anybody knows of such an implementation ?
Thanks in advance,
Best Regards,
Gaurav
|
|
|
|
|
Just google for source code for AES if you want to roll your own. However, I believe the built-in MS crypto providers have a certified implementation of AES. I can't double check now, since I'm not at work, but I know I used the built-in AES for a previous customer who was rather anal about certified algorithms. That was XP however. It's been too long since I worked on the Mobile Windows variants to know if the full crypto is supported in those OSes. Worth checking before writing your own.
Judy
|
|
|
|
|
hey,
thanks for the suggestion .. for the time being i have found an AES implementation that worked for me .. but its a gud idea to luk for built in
support of AES in Windows Mobile .. wud do tht ..
do you think built in imlementations would be faster than the googled ones ...
|
|
|
|
|
Hello,
I am desesperate! I know that you post about AES encryption for windows mobile a long time ago... But I would be so grateful if you could tell me how do you solve your problem and how do you implement the encryption on WM.
Thanks in advance! I hope you can help me.
|
|
|
|
|
I've a tab control inside a Dialog that I would like to resize.
After getting unexpected results I created this sample code:
GetWindowRect(&Screen1);
Client1 = Screen1;
ScreenToClient(&Client1);
GetClientRect(&m_ClientRect);
SetWindowPos(NULL, m_ClientRect.left, m_ClientRect.top, m_ClientRect.right, m_ClientRect.bottom, SWP_NOCOPYBITS || SWP_NOOWNERZORDER || SWP_NOREDRAW);
GetWindowRect(&Screen2);
GetClientRect(&Client2);
Result:
Screen1 {top=0x000001ca bottom=0x000002ef left=0x00000253 right=0x0000035e}
Screen2 {top=0x000001c5 bottom=0x000002ea left=0x000001be right=0x000002c9}
Client1 {top=0x00000000 bottom=0x00000125 left=0x00000000 right=0x0000010b}
Client2 {top=0x00000000 bottom=0x00000125 left=0x00000000 right=0x0000010b}
m_ClientRect {top=0x00000000 bottom=0x00000125 left=0x00000000 right=0x0000010b}
Getting the window pos (Screen1) and converting to Client Pos (Client1) gives the same result like directly retriving the client position (m_ClientRect).
Also getting the client position after the SetWindowPos (Client2) gives the same results like before.
Nevertheless the window has moved since the screen coordinates before/after calling SetWindowPos (Screen1/Screen2) are totally different.
Where does this behaviour come from, what can I do to avoid it?
Regards
Leo
|
|
|
|
|
Chilli71 wrote: Where does this behaviour come from
It comes from the fact that you're getting the client rect when you're calling GetClientRect() , and then you're telling Windows to use this rect as the new windows rect. They are not the same - window rects includes borders, client rects do not. If you want to set a new window rect, call GetWindowRect() .
|
|
|
|
|
I suppose you are telling the right thing and pointing out the wrong function.
A dc is also available. Maybe I should take some dc position functions?
I thought GetWindowRect returns the coordinates in screen coordinate system while GetClientRect returns the coordintaes relative to the parent window.
That's what I wanted to proof by using ScreenToClient to confirmn that the result is the same.
The description of SetWindowPos tells to use client coordinates. That's why I've choosen to use the GetClientRect.
According to what I understood from you answer this should work
GetWindowRect(&Screen1);
Client1 = Screen1;
ScreenToClient(&Client1);
GetClientRect(&m_ClientRect);
SetWindowPos(NULL, Screen1.left, Screen1.top, Screen1.right, Screen1.bottom, SWP_NOCOPYBITS || SWP_NOOWNERZORDER || SWP_NOREDRAW);
GetWindowRect(&Screen2);
GetClientRect(&Client2);
delivers
Screen1 {top=0x00000140 bottom=0x00000265 left=0x000001cf right=0x000002da}
Screen2 {top=0x0000027b bottom=0x000003a0 left=0x00000309 right=0x00000414}
Client1 {top=0x00000000 bottom=0x00000125 left=0x00000000 right=0x0000010b}
Client2 {top=0x00000000 bottom=0x00000125 left=0x00000000 right=0x0000010b}
m_ClientRect {top=0x00000000 bottom=0x00000125 left=0x00000000 right=0x0000010b}
Again the window is moved.
Greetz
Leo
|
|
|
|
|
From MSDN on CWnd::SetWindowPos() : All coordinates for child windows are client coordinates (relative to the upper-left corner of the parent window's client area). So your code would work the way you expect if you used Client1 instead of Screen1 in SetWindowPos() .
|
|
|
|
|
If you look at my original posting and compare the results of the variables you see that is does not work.
thx
Leo
|
|
|
|