|
Yes, because actually looking at your warnings is apparently too difficult.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Joe Woodbury wrote: Yes, because actually looking at your warnings is apparently too difficult.
I had a manager once, who was quite skilled in C programming, but who would often leave warnings in his code if he thought they were trivial...which left him open to missing new warnings that weren't. He's a lawyer now.
|
|
|
|
|
Ahh, those with negative men points could always use
#define equals ==
which brings a nice touch to the code
int a = 3;
if( a equals 3)
{
...
}
But why stop here, just add the following
#define if if(
#define then ){
#define endif }
And youre code will look like this
if a equals 3 then
...
endif
It somehows reminds me of another language, I just can't get my fingers on the name ...
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
LOL. I remember someone suggesting defines like this:
#define please
#define thanks
And the code would be much more pleasant to read:
please do {
...
} while (i < imax);
thanks
|
|
|
|
|
Doesn't LOLCode do something similar to this?
HAI
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
AWSUM THX
VISIBLE FILE
O NOES
INVISIBLE "ERROR!"
KTHXBYE
Imagine that you are hired to build a bridge over a river which gets slightly wider every day; sometimes it shrinks but nobody can predict when. Your client provides no concrete or steel, only timber and cut stone (but they won't tell you what kind). The coefficient of gravity changes randomly from hour to hour, as does the viscosity of air. Your only tools are a hacksaw, a chainsaw, a rubber mallet, and a length of rope.
Welcome to my world.
-Me explaining my job to an engineer
|
|
|
|
|
I laughed really hard at this one!
To those who understand, I extend my hand.
To the doubtful I demand: Take me as I am.
Not under your command, I know where I stand.
I won't change to fit yout plan. Take me as I am.
|
|
|
|
|
You haven't dealt with object equality.
I know as a random key monkey, it's very dificult for me to remember that
objA == objB
is not the same as
objA.equals(objB)
Can you provide the best answer. I have to get the bugs out of the LCG framework before Thursday!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Guideline 1: Always compile cleanly on warning level 4.
--
Time you enjoy wasting is not wasted time - Bertrand Russel
|
|
|
|
|
Johann Gerell wrote: Guideline 1: Always compile cleanly on warning level 4.
Gudeline 2: Turn on the option: "Treat warnings as errors".
|
|
|
|
|
Even better, you could use #pragma to convert that particular warning into an error (I think it's possible anyways)
|
|
|
|
|
Nemanja Trifunovic wrote: Gudeline 2: Turn on the option: "Treat warnings as errors".
I do that for release builds, but not debug.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Actually, writing
if (x = 0) ...
does not generate any warning at all (at least in VS 2005). Looks like this is a flaw in the compilor.
|
|
|
|
|
ed welch wrote: Actually, writing
if (x = 0) ...
does not generate any warning at all (at least in VS 2005).
Of course it does. But you have to enable warning level 4 (as I pointed out in the "guideline") in the project property pages under C/C++ > General. Then you get this:
warning C4706: assignment within conditional expression
If you also set that warnings should be treated as errors, you get this:
error C2220: warning treated as error - no 'object' file generated
warning C4706: assignment within conditional expression and that way you just cannot miss the assignment.
--
Time you enjoy wasting is not wasted time - Bertrand Russel
|
|
|
|
|
first thing if programmer is dump then he can make any mistake... No one gud programmer will do this sort of mistake... So Guidelines for stupid programmer only...
As u know why this guidlines..
if(0 == x) : should use as guidelines
if(x == 0) : should not use
why first one is appreciated for stupid programmer coz he may write as if(0 = x) then error will come in this case in all compiler and second one will not give any error in max compiler...What hell this goin on...How any programmer do this mistake??? I cannt believe...
Truth Can'nt be changed
|
|
|
|
|
The problem with if(0 == x) is that we don't naturally read or write that way. It's Yoda-speak[^]: if x is 0 will become if 0, x is .
Unnatural actions have a tendency to not stick naturally.
Time you enjoy wasting is not wasted time - Bertrand Russel
|
|
|
|
|
Depends on the compiler:
Borland C++ 5.5 for Win32 reports:
Warning W8060 xtc.c 14: Possibly incorrect assignment in function main
As usual, HP C V7.3-009 on OpenVMS Alpha V8.3 takes it to a whole other level:
CHECK Messages reporting code or practices that,
although correct and perhaps portable, are
sometimes considered ill-advised because
they can be confusing or fragile to
maintain. For example, assignment as the
test expression in an "if" statement.
NOTE: The check group gets defined by
enabling LEVEL5 messages.
LEVEL4 Useful check/portable messages.
LEVEL5 Not so useful check/portable messages.
CC/WARNING=(ENABLE=LEVEL5,VERBOSE) TEST.C
if ( argc = 1 )
....^
%CC-I-CONTROLASSIGN, In this statement, the assignment expression "argc=1" is used as the controlling expression of an if, while or for statement.
at line number 14 in file MY$ROOT:[000000]TEST.C;2
Description: A common user mistake is to accidentally use assignment operator "=" instead of the equality operator "==" in an expression that controls a transfer. For example sayin
g if (a = b) instead of if (a == b). While using the assignment operator is valid, it is often not what was intended. When this message is enabled, the compiler will detect these
cases at compile-time. This can often avoid long debugging sessions needed to find the bug in the user's program.
User Action: Make sure that the assignment operator is what is expected.
printf ( "Hello, %s!" , argv [ 1 ] ) ;
........^
%CC-I-IGNORECALLVAL, In this statement, the value returned from the function "printf(...)" is not used - if this is intended, it should be cast to "void".
at line number 16 in file MY$ROOT:[000000]TEST.C;2
Description: A function that returns a value has been invoked, yet the value was not used. This might not have been what you intended.
User Action: Cast the function to void to suppress the message.
CC/WARNING=(ENABLE=CONTROLASSIGN) TEST.C
if ( argc = 1 )
....^
%CC-I-CONTROLASSIGN, In this statement, the assignment expression "argc=1" is used as the controlling expression of an if, while or for statement.
at line number 14 in file MY$ROOT:[000000]TEST.C;2
|
|
|
|
|
PIEBALDconsult wrote: As usual, HP C V7.3-009 on OpenVMS Alpha V8.3 takes it to a whole other level:
Wow! I wonder how much money HP could get by porting their warning reporter into a visual studio plugin?
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
It's easier for me to remember the == than it is to remember to write the condition backwards.
|
|
|
|
|
When posting to the forums, it's perfectly acceptable to post C/C++ questions in the C# forum because they've all got C somewhere in there name. Of course, this also means you can ask COBOL questions in there as well but that's the price you pay.
Sod it - you can always throw Java questions in there because they've got curly brackets as well.
|
|
|
|
|
Yes, this is a decent standard, and has been recommended by some very prestigious programmers (Allen Holub comes to mind).
|
|
|
|
|
No, I will never do this.
I would leave the job interview if I was 'corrected' on this when I wrote code.
|
|
|
|
|
I need to refresh the hardware device list in the Device Manager instead of manually rescan for the hardware changes by right clicking on any of the device and selecting the option for "Scan for hardware changes",
i need to do it using C# code.is there any way to invoke the dll to perform the rescanning of all the hardware device,
I need this because Non-PNP device will not be automatically detected by windows.
thanks and regards
vinayskvs
|
|
|
|
|
you need a lot of things. Possibly, you need also to hit the right forum.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
May i know in forum do i need to post my question..?
|
|
|
|
|
I guess the C# one is more appropriate.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|