|
Hi man
Sorry my ignorance about this but In Settings->C/C++->Code Generation->calling convention I have a __cdecl *
Is this wrong? right?
I don't know how to make this work, and worse I don't know why is not working.
Best Regards
Dr. Pi
|
|
|
|
|
Sorry I've made a mistake typing
I typed
return (q[*b].accept-q8[*a].accept); //q is an struct
and it has to be
return (q[*b].accept-q[*a].accept); //q is an struct
The call is this line
qsort((void *)order,BLQ_EIGHT,sizeof(short int), accept);
Best Regards
Dr.Pi
|
|
|
|
|
This should get you close:
int accept( const void *p1, const void *p2 )
{
short int *n1,
*n2;
n1 = *((short int *) p1);
n2 = *((short int *) p2);
return n1 - n2;
}
...
qsort((void *) order, BLQ_EIGHT, sizeof(short int), accept);
|
|
|
|
|
Several problems :
1. int AppDoc::accept(...)
qsort requires a C function, you can not pass a non-static class method.
2. The prototype does not match that specified for qsort.
In particular qsort requires the function to look like :
int compare(const void *elem1, const void *elem2);
You can get around this via casting of elem.
3. (related to 1) If you are going to define a C compare function in a C++ header/source file then you need to wrap the declaration in (to prevent C++ name mangling) :
#ifdef __cplusplus
extern "C" {
#endif
int compare(const void *elem1, const void *elem2);
#ifdef __cplusplus
}
#endif
4. You are passing indicies to an array of struct q, chances are you want to sort q, in which case you need to pass the q array to qsort and pass pointers to the q struct to the compare function. I don't know what order is ?
5. (not a problem, but change anyways) You have a method named accept in AppDoc and a field named accept in struct q ... stop it.
...cmk
|
|
|
|
|
Hey, I want to export some object paintet (MFC OnDraw-function)to a bitmap. When I use BitBlt Dialogs appear in the final bitmap too...
I'd like to have only my painted Objects....
|
|
|
|
|
I'm inheriting a project which has a lot of static libraries (hardware control). Can I just create a dll (using VS wizard) and link the static libaries into one dll with no troubles?
Bit of a newbie in this arena....I haven't worked with DLLs much.
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
Are you trying to write wrapper functions for all the functions in the static libraries or do you just want to use the functions in the static libraries in the DLL? If you can make it a bit more clearer, I will be able to help you out...
|
|
|
|
|
No wrapper necessary. I'd like to just them as they are...just in the DLL.
The static libs are fine as they are...I'd just like to have open one time, in one instance in memory instead of building them in to every test program I'm going to write which uses them.
Appreciate your advice.
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
When I use Purify and Visual Studio to debug my program,
The Purify can't run within visual c++ because of the DLL's incompatible.
And when I use purify alone to run my program, It says the above problems.
How to solve this?
thanks.
|
|
|
|
|
Possible scenario:
Lib (A) links to Release build of VCRT
Application: links to Lib (A) and Debug Build of VCRT
problem: Debug build of VCRT adds some "guard bytes" after each allocation; allocating memory with the release build, and free'ing it with the debug build (or vice versa) can fail
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Hi there.
I have created an MDI program, and I need to know, where do I add the filters used when a user does a File->Open? Sorry if this is an inane question, but I'm used to using Borland C++ Builder, and obviously VS .Net does things differently.
Thanks!
James A Beggs
American Quarter Horse Association
Manager of Product Development
|
|
|
|
|
Are you using CFileDialog or GetOpenFileName()?
|
|
|
|
|
I, uhm.... dont know?
I used the wizard to generate an automatic MDI for me, and it set up the parent's menu system and everything. It had a section in the wizard for inputting the file name to open, but I decided to add more to it.
The main application class inherits from CWinApp. The wizard automatically created a Message Map that maps its file->open to CWinAPP::OnFileOpen
(Man, I feel stupid. I wouldn't think working on something so simple would have been so hard when translating from Borland C++ Builder to VS .Net. I guess C++ Builder's RAD spoiled me :/ )
James A Beggs
American Quarter Horse Association
Manager of Product Development
|
|
|
|
|
Sounds like you simply need to modify the IDR_MAINFRAME string in the resource file.
|
|
|
|
|
Well... it has a string in the string table, IDR_ImageFileMasterTYPE (the name if the application is Image FileMaster), and it contains the string that is listed when you do a File->Open, including a path, a filter, etc.
But, in modifying the string so that it contained more than one filter made no difference; it listed the new string in the file->open dialog, but didn't actually show the new file extensions.
James A Beggs
American Quarter Horse Association
Manager of Product Development
|
|
|
|
|
Probably because an MDI app, by default, does not know how to handle more than one file type. Read MSDN article Q141921.
|
|
|
|
|
Well, how irritating. I changed the string, as it said, but according to the article, it wasn't enough. Oh well, thanks for the pointer to the article!
James A Beggs
American Quarter Horse Association
Manager of Product Development
|
|
|
|
|
James A Beggs wrote:
I changed the string, as it said, but according to the article, it wasn't enough.
Right, you must implement at least the first four steps in order to achieve the desired results. Simply changing the string does nothing. I would suggest stepping through the MFC code for opening documents to see what is going on. Knowing how/why MFC does what it does is always helpful.
|
|
|
|
|
I think I'll also be getting a book on MFC, as I haven't really worked with it either.
Thanks again.
James A Beggs
American Quarter Horse Association
Manager of Product Development
|
|
|
|
|
Actually, could you suggest a good book on MFC?
James A Beggs
American Quarter Horse Association
Manager of Product Development
|
|
|
|
|
"Good" is in the eye of the reader! I have Kruglinski's Inside Visual C++ (which includes nothing for v6), and Mastering MFC Development Using Microsoft Visual C++ 6.0 by Microsoft Press.
I believe all books are intended for a particular target audience. I've read very little of either book because most of what they contain I've known about simply by using MFC from its inception (see my earlier note on stepping through code). I'm no MFC expert, and probably learn 1-2 new things about it each week.
|
|
|
|
|
I want to install the "Standard 19200 bps Modem" in Windows
programmatically and set some modem properties like "Use flow control" (AT commands)
etc .
Any pointers would be very helpful.
Regards,
Ajith
|
|
|
|
|
Hi all
How do I measure the time taken to execute a function? I'm working on a real time project at the moment so I want to know how fast my program would go. I've noticed the function time(time_t *) but I don't know how it works. Can anybody please give me some codes on how to use it?
Thanks a lot
|
|
|
|
|
Heres an article i wrote a while back, it should give a good idea how to clock your functions.
http://www.codeproject.com/cpp/profiler.asp
Cheers
"Two wrongs don't make a right, but three lefts do!" - Alex Barylski
|
|
|
|
|
For Win32/x86 the most accurate is:
class CHPFCounter
{
public:
__int64 m_started;
void Start()
{
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
m_started = li.QuadPart;
}
double Time()
{
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
__int64 ticks =li.QuadPart - m_started;
QueryPerformanceFrequency(&li);
double seconds = (double) ticks / li.QuadPart;
return seconds;
}
};
Time() returns time in seconds (resolution is around CPU clock).
However, it's recommended to
a) measure each snippet multiple times, to see variations
b) verify the assembly that you indeed measure what you think you measure
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|