|
If you accidentally write "=", but not "==" which you originally want it to be, then in the first case, compiler will tell you this mistake.But in the second case, compiler will not do this.
This only prevent you to make mistakes, but I don't think this is necessary
|
|
|
|
|
Most newer compilers will give you a warning for doing an assignment operator in a conditional statement.
|
|
|
|
|
I don't know which compliers you refer to, but when I test it with VS2005(which I am using now), it doesn't give any warning.Of course, here I'm using the default warning level: level 3.
When I change it to Level 4, it indeed give a warning
|
|
|
|
|
You should always use level 4.
There shouldn't be lesser levels.
|
|
|
|
|
That's a pattern that is generally held to be rubbish nowadays.
It only works when comparing an lvalue with an rvalue, and if you can remember to do it then you can remember to use the intended operator.
|
|
|
|
|
I've always viewed the difference as purely cosmetic or "style" of the coder. Personally, I've always disliked the (NULL == p) style because when I look at code for debugging, my brain processes left to right so I want to read "if p is NULL".
|
|
|
|
|
There is no difference between (NULL == p) or (p == NULL)
Both are same.
Actually it always better to prefer ( NULL == p )
Why because,
To aviod the accident of assignment that can happen.
say you are writing a statement (p == NULL ), but accidentally you wrote as p = NULL then the whole meaning is changed.
But if you use ( NULL == p ) then forgetting to give NULL = p will give compiler error.
From early days of programming this was a common error, so it now a standard to use as (NULL == p), which applicable to all the constants. It is always better to write constants on right side.
Величие не Бога может быть недооценена.
|
|
|
|
|
Hi,
I hereby claim first post!.
Thank you for helping, it is appreciated.
Could someone share with me how we can simulate a user moving the mouse around and clicking on stuff?
I need to know how you tell the mouse go there (meaning to any pixel of the lcd), click, wait go there, click again, etc.
This kind of behavior is mostly documented on the internet for situation that appears to be within the program's window using setcursorpos, getcursorposition for example: http://en.allexperts.com/q/C-1040/2008/1/Mouse-Tracking.htm[^]
Thank you
Antoine
|
|
|
|
|
Hi,
search for the SendInput() function and the INPUT and MOUSEINPUT structures.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
Messing around trying to learn something and I'm having trouble seeing the time benefits in my openMP example.
Each array (pArray1 and pArray2) hold about 10meg of RGB bitmap data, bufferSize2 is the bmp file size. OpenMP is enabled in VS.
So I can run the following with or without #pragma and get the same 20Msec's or there about.
<br />
<br />
#pragma omp parallel for //<-no impact on time<br />
for(long loop=0;loop<bufferSize2;loop++)<br />
pArrayResult[loop]= ~(pArray1[loop] - pArray2[loop]);<br />
<br />
I can try the common openMP example:
<br />
#pragma omp parallel<br />
{<br />
printf("hello world");<br />
}<br />
and never get something that looks like the example warning
helhelloo w world orld
I always get
hello world hello world
I can try
<br />
#pragma omp parallel<br />
{ <br />
int ID=omp_get_thread_num();<br />
printf("Hello(%d)",ID);<br />
printf("world(%d)",ID);<br />
}<br />
and the result is always sequential
hello(0)world(0) hello(1) world(1)
Anyone have an idea as to why everything seems sequential? What am I doing wrong?
Thanks,
Andre
modified on Friday, October 23, 2009 8:59 AM
|
|
|
|
|
Bump. Ow, no Bump.
modified on Friday, October 23, 2009 12:27 PM
|
|
|
|
|
I'm trying to fix an MFC app that puts up a "Failed to create empty document" for some customers when they try to open a data file. It hasn't failed on any of our own systems or for our customers in North America, but only for a customer in Sweden and one in Australia. It fails in both Win XP and Vista. The user has admin privileges. I installed those on a test machine of my own, setting the language to Australian and the locale to Australia, and installing the same anti-virus as the Australian customer, but nothing I do can reproduce the problem locally.
It's failing somewhere in MFC's OpenDocumentFile() function. Does anyone have an idea why it would work fine in the United States, but fail in Australia? It's not even reading a file yet, just trying to create an empty doc.
Thanks in advance for your help.
Dave Goodman
dgoodman@infoway.com
dkgoodman.com/blog.html
"Actio sequitur esse."
|
|
|
|
|
Dave,
I was adding some functionality to an MFC app that has been running for 10 years. I started getting the "Failed to create empty document" message. I stepped into the constructor of my document class and its base class and all the other objects that were being created. The constructor of one of my objects was getting a pen style out of a configuration file that contained a bogus value. The class was attempting to create a pen with "new CPen(..." using the bogus pen style value. The constructor of CPen threw an exception eventually causing the document class to exception out resulting in the infamous "Failed to create empty document" message. Perhaps your customers in Sweden and Australia have some bogus data in either their data files or some configuration file.
|
|
|
|
|
What does additional exception params mean. How to decode them
Exception code: c0000417
Additional params 1: bc2f
Additional params 2: a1e3a477b6e1fdbadac6c68bdf7431d9
Additional params 3: a3b3
Additional params 4: 7bd20c8dcbae52a3e1bbda9149a93f62
Чесноков
|
|
|
|
|
Hi,
My dll is creating connection to a sybase database. I am using ex_connect to connect the sybase.But while i am trying to build the code,after coming to the function ex_connect my debugger is not returning anything.Neither it is giving any error nor returning anything.
But while i used the same code(written in dll) in an executable file to test, it was working fine.
I need your help. Thanks in advance.
|
|
|
|
|
I have Dialog Box in SDI application. How to write data from Dialog to Document not closing the dialog box (just clicking the button).
Thanks for any help
BC
|
|
|
|
|
Make the dialog modeless.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
OK. I have changed my dialog to modeless but how to interact between dialog and document. For example:
In dialog I have number in edit box and on click "add" button I want this number to be written in new line on document.
Thanks for any help.
|
|
|
|
|
kudlaty79 wrote: OK. I have changed my dialog to modeless but how to interact between dialog and document.
Post a message to it. When the document receives the message, it can then notify the view (i.e., UpdateAllViews() ) that it needs to render the new data.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
OK.
But can you give an example?
like:
when clicked add on dialog write "hello" on document
Thanks for help.
|
|
|
|
|
Assuming the dialog is modeless, call PostMessage() with some user-defined message and a pointer to some heap-based data (i.e., new ) as the LPARAM . Provide a handler for that message in the document class. In that handler, update the document's data with the contents of LPARAM . Then call UpdateAllViews() . In the view' OnUpdate() method, it will get the latest data from the document and render it.
Aside from the dialog, all the rest is just plain MFC stuff.
You can test most of this by creating a sample SDI application. Add a CString member variable to the document and assign it some value. In the view's OnUpdate() method, get access to the document's data by calling GetDocument() plus whatever name you gave the member variable. Now render that data using the supplied DC's TextOut() method.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi
I have a great idea for a new virtual world which will be written in C++ and was wondering if someone would like to help with this project which I might need help with. It's a great design and should be easy to program. Members will be able to create a character, purchase and build houses, go shopping, chat with friends and much more in 3D.
Thanks
Andrew
Andrew McIntyre
|
|
|
|
|
|
A "great idea" is one thing, implementing it is another.
You're probably looking at 5 man-years work just to get a basic, reliable system up and running, and well over 20 man-years for a fully-featured, immersive system. Even something as crude as Second Life has had a huge amount of development time spent on it (and most people would expect much higher quality in any new offerings).
Rather than trying to built this from scratch yourself, you might try looking for a job at one of the companies already developing in this area.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|