|
Is it possible to run GCC within Microsoft's IDE (6 or .NET, it doesn't matter which), I just want to test some template code.
I know that it is possible because comeau and the intel compiler do it, but has anyone seen it for GCC.
thanks
|
|
|
|
|
Try the following links.
http://sources.redhat.com/ml/crossgcc/2001-05/msg00046.html
http://www.cygwin.com/ml/crossgcc/2001-09/msg00069.html
-Tareq
|
|
|
|
|
Hello
Does anyone know a url where i can find an extensively comparison between Visual C++ 5.0 and the 6.0 version? Like for example: 6.0 version had this as advantage, this as disadvantage etc
Greetings
Jens
|
|
|
|
|
I just spent the best part of today finding a nasty little bug and thought I might "share" with you.
We had some code that basically went
{<br />
CPen apen;<br />
apen.CreatePen(...);<br />
dc->SelectObject(&apen);<br />
<br />
<br />
dc->SelectStockObject(BLACK_PEN);
}
Last version, the code was changed to something like
{<br />
if (option)<br />
{<br />
CPen apen;<br />
apen.CreatePen(...);<br />
dc->SelectObject(&apen);<br />
<br />
}<br />
else<br />
{<br />
CPen bpen;<br />
bpen.CreatePen(...);<br />
dc->SelectObject(&bpen);<br />
<br />
}<br />
dc->SelectStockObject(BLACK_PEN);
}
I am sure you can see the error... apen and bpen are now being destroyed before selected out. Resource leak.
Running this code on Win2000/XP is fine because they clean up the mess. Running on 95,98,ME caused massive resource leaks (obviously!) The error is obvious when simplified as above but it was not the least bit obvious in the production code.
It's always the simple things that bite you!
Paul Hooper
If you spend your whole life looking over your shoulder, they will get you from the front instead.
|
|
|
|
|
CPen* pOldPen = dc->SelectObject(&apen);
//Do lots of work with dc
dc->SelectObject(pOldPen);
or you could just use SaveDC() and RestoreDC() so you do not have to keep track of what objects are selected.
int nSavedDC = dc->SaveDC();
dc->SelectObject(&apen);
//Do lots of work with dc
dc->RestoreDC(nSavedDC);
Trust in the code Luke. Yea right!
|
|
|
|
|
Oh! One more thing, do not do this:
if(..)
{
CPen apen;
....
dc->SelectObject(&apen);
}
Unless you are going to restore the old pen before leaving the 'if' block, because (of course) apen goes out of scope as soon as you leave the block.
CPen apen;
if(..)
{
....
dc->SelectObject(&apen);
}
Also it you must use CPen::CreatePen(), instead of the constructor, to create your pens then you must call CPen::DeleteObject() to destroy it or you will get memory leaks.
Trust in the code Luke. Yea right!
|
|
|
|
|
Hi,
In a dialog based application (main application window), a frame window
can be drived by click a menu item. Now my problem is that i want use some functions defined at the appDlg.cpp, how should i call these functions in myframe.cpp? How the communications are constructed ?
Thanks in advance!
chen
|
|
|
|
|
Three solutions :
1. Use user defined messages with SendMessage or PostMessage .
2. Overwrite the Create (Or DoModal ) function of the frame window to add a pointer to a CYourDialog (where CYourDialog is the name of your dialog) as parameter. Put a member variable m_pMainDlg in your Frame window class, and store the pointer in it. Call your base class functions with
m_pMainDlg->Function1();
3.[MFC] Use AfxGetMainWnd() in a type cast :
CYourDialog *m_pMainDialog = (CYourDialog*)AfxgetMainWnd();
m_pMainDlg->Function1();
~RaGE();
|
|
|
|
|
Hello....
I am having problems when I am trying to drag and drop one of my activeX control from an application to MS-WORD.
The problem is that I am not sure what format it is for an ActiveX Control in clipboard (ie. CF_TEXT is for text) so I dont know what to put as the first parameter in the function when I need to cashe my data into the global memory created ....
"opOleDataSource->CacheGlobalData(??????, hGlobal);"
Does anyone knows how to do this and Please advise me !!
Thank You !!
|
|
|
|
|
I have some problems with my code here. You can see where the error appears in the code:
char szCommand[] = "luc 192.168.244.151 5000 50 mypass";
void HotIceParser(const char* command, PHIPD phipd)
{
char buffert[20+1] = {0};
char* p1 = NULL;
char* p2 = NULL;
#ifdef DEBUG_MODE
assert(phipd != NULL);
#endif
p1 = &buffert[0];
p2 = &command[0];
while((*p2 != ' ') && (*p2 != '\0'))
*p1++ = *p2++;
MessageBox(NULL, buffert, "1",MB_OK);
if(strcmp(buffert,"luc") == 0)
{
phipd->type = LUC;
p1 = &buffert[0];
p2++;
while((*p2 != ' ') && (*p2 != '\0'))
*p1++ = *p2++;
MessageBox(NULL, buffert, "2",MB_OK);
strcpy(phipd->luc.pszIP, buffert);
}
}
Can you help me to solve this?
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Do you really NEED to use C? Your line
char buffert[20+1] = {0};
seems to be C++ to me: I C, you would use zeromem() or memset().
But if using plain, ugly C is not of prime importance, because you use a C++-compiler anyway, you can just as well use std::string to do the parsing:
void HotIceParser(const char* cmd, PHIPD phipd)
std::string command( cmd );
std::string::iterator p1 = command.find_first_not_of(' \0'); ..and so on..
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
jhwurmbach wrote:
Do you really NEED to use C
Hm... in fact no. But I want to learn it.
jhwurmbach wrote:
char buffert[20+1] = {0};
seems to be C++ to me:
I C, you would use zeromem() or memset().
Thanks!
I want perfect C code!
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
char buffert[20+1] = {0};
This is C. When you initialise a buffer like this the buffer is initialised to all zeros.
char buffert[20+1] = {'\0'};
or
char buffert[20+1] = {(char)0};
is more correct.
char buffer[4] = {'1'} produces a buffer containing the follwing:
'1','\0','\0','\0'
Trust in the code Luke. Yea right!
|
|
|
|
|
I am presuming that you are sending szCommand to the function. szCommand is longer than 20 characters and buffert will only hold 20. Your while loop will keep filling buffert past the 21 limit of your array and corrupt whatever is around.
You need to check that your command parameter is not bigger than buffert.
Paul Hooper
If you spend your whole life looking over your shoulder, they will get you from the front instead.
|
|
|
|
|
Paul Hooper wrote:
I am presuming that you are sending szCommand to the function
Yes.
Paul Hooper wrote:
szCommand is longer than 20 characters and buffert will only hold 20.
Yes, but it's strange when Rage could get it to work... and me too...
Paul Hooper wrote:
You need to check that your command parameter is not bigger than buffert.
Thanks!
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Rickard Andersson18 wrote:
Yes, but it's strange when Rage could get it to work... and me too...
Not strange at all. Once you overrun a buffer ANYTHING is possible - depending on what has been overwritten. Anywhere from complete system compromise, pain, suffering, earthquakes, volcanoes (oops getting a little carried away) to ... absolutely nothing. These are really nasty faults BECAUSE the results can be variable. Just ask Microsoft!
Paul Hooper
If you spend your whole life looking over your shoulder, they will get you from the front instead.
|
|
|
|
|
i have tried it out, and it works perfectly.
Only changed
char* p2 = NULL;
in
const char* p2 = NULL;
~RaGE();
|
|
|
|
|
Yeah, I've tried it also now and it worked... strange!
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
You don't appear to be null-terminating buffert . Just before the MessageBox() call, do a *p1 = 0 . AFAIK, your initialiser only sets the first location of the array to 0 - all the rest are left uninitialised.
Also, make sure that your buffert array is not being overrun - your code as written is a big security hole. What if somebody managed to send 22 characters without a space? If you're lucky it would crash. If not, who knows what data might get corrupted...
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
AFAIK, your initialiser only sets the first location of the array to 0 - all the rest are left uninitialised.
AFAIK the ={0}; does the same as zeromem() does - only that it is more pleasant to the eye.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Fair enough. I'll remember that
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thank you very much!
I've updated the code, here is the updated version:
void HotIceParser(const char* command, const int len, PHIPD phipd)
{
char* buffert = NULL;
char* p1 = NULL;
const char* p2 = NULL;
#ifdef DEBUG_MODE
assert(phipd != NULL);
assert(len < MAX_BUFFERT+1);
assert(len != 0);
#endif
buffert = (char*)malloc(len);
ZeroMemory(buffert, len);
p1 = &buffert[0];
p2 = &command[0];
while((*p2 != ' ') && (*p2 != '\0'))
*p1++ = *p2++;
if(strcmp(buffert, HIC_LUC) == 0)
{
phipd->type = LUC;
p1 = &buffert[0];
p2++;
while((*p2 != ' ') && (*p2 != '\0'))
*p1++ = *p2++;
*p1 = '\0';
strcpy(phipd->luc.pszIP, buffert);
}
free(buffert);
}
Is there anything that you think is done wrong or so?
One thing I don't really understand is:
while((*p2 != ' ') && (*p2 != '\0'))
*p1++ = *p2++;
Is command contains this: "luc 192.168.244.151 4000 50 mypass".
Then it only run the loop 3 times because it is supposed to find 'luc'. If I remove "&& (*p2 != '\0')" it will loop many times, I don't know how many but many! With "&& (*p2 != '\0')" I will understand it as it would keep iterate until '\0' is also found... but it doesn't. I did wrote the code by myself but I don't really understand it correctly!
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
I have been programming in C and C++ for a little while now, but I want to start learning the MFC stuff. I have been looking through the MSDN library, but I could not seem to find much information on where to start in the learning process. I have manipulated a few Visual C++ apps to do what I need them to do, but I'm not sure what some of the code did. So here is my list of simple questions:
1. What are the most helpfull resources to use?
2. Did I miss a section of the MSDN library that is helpful in this area?
3. When I start a new Win32 Project, how much of the automatic code do I need to understand?
4. What other basic tips can you provide for someone in my situation?
by the way,
I'm using Visual Studio .net
|
|
|
|
|
Jon H wrote:
1. What are the most helpfull resources to use?
To a certain extent learning MFC is a bit of trial and error. The way I learnt was by starting with dialog based apps.
Play around with the toolbox and adding controls. Then start to add controls to your app. Finally make sure you understand how to add variables to represent the controls with various ID's.
Jon H wrote:
2. Did I miss a section of the MSDN library that is helpful in this area?
Possibly what you missed is that MFC is huge. It's made up of so many classes which represent so many different types of controls
Jon H wrote:
3. When I start a new Win32 Project, how much of the automatic code do I need to understand?
Very little to start with. Try to avoid modifying message maps unless you have to. Stick, at least at the start, to just worrying about your handlers for buttons / whatever. Don't worry much about the code the AppWizards generate for you, most of it's just framework stuff. If you need to modify it you can get more help on MSDN. Look for the todo: in the code for place's where you can start to add code if you feel the urge to experiment.
Don't make the mistake of trying to cram your whole app into the generated MFC classes. Write your app, then use MFC as a frontend, using whatever goodies you want like CString along the way.
Jon H wrote:
4. What other basic tips can you provide for someone in my situation?
Be aware of linking. Sometimes I think this is the most underdone of all C++ topics. Make sure that you're linking to the correct standard library. Be aware of unicode compliance. Use string tables if you start thinking about developing a bigger product
|
|
|
|
|
hi
I get a linker error (WinMain@16 or something like that) when I try to build my app with unicode.
I've defined the _UNICODE macro in the config-settings. Are there any other steps necessary to successfully build a unicode app ?
different question:
I have, for example, 2 string tables (1x german, 1x english) or dialog templates... (german is default)
Now the question -> What steps are necessary to make a build with the english
resources ?
thanks
widi
vc6 sp5, mfc, winxp
|
|
|
|