|
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]
|
|
|
|
|
Nooo, the idiot has asked the same question for weeks now...
|
|
|
|
|
OMG: I didn't know.
Thank you for pointing out.
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]
|
|
|
|
|
So, this is actually the RIGHT forum then ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I posted the question on 5th Sep 2008 but I didnt get the solution for my question, i dont know this is the right forum or not, is there anybody to help me to solve my problem..
|
|
|
|
|
I mean, this is the right forum for coding horrors, hence the name. Therefore, if this question is a 'horror', then this is the right place to ask it.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Sorry boss, you know onething im new to C# i need some support for me to learn new things, thats why i registered for this site.
do you think you are great or something to call some one Idiot. Even i can reply with many others words in different language too.. but im not like you Mr.__
just dont see the question if possible reply, im poor in english if u dont understand tell me i will explain my problem in pages and i will post it from next time..
OKAY
|
|
|
|
|
I suggest you use an online translation service, such as Babelfish, to translate...
"Do not post programming questions in this forum"
into the language of your choice.
Only then may you be able to comprehend the true meaning of the above statement.
If you don't do this, or are unable to understand after that step, then you truly are an idiot!
I still remember having to write your own code in FORTRAN rather than be a cut and paste merchant being pampered by colour coded Intellisense - ahh proper programming - those were the days
|
|
|
|
|
Okay Baconbutty, i will not post messages to this forum.
|
|
|
|
|
Try the C# forum located here:
http://www.codeproject.com/script/Forums/View.aspx?fid=1649
Bill W
|
|
|
|
|
Dude, do you have the slightest frigging clue what this forum is for? It is for sharing coding horrors one has found while working, not for programming questions. Geeze
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
This is a real code
Magic.cpp:
#include"Magic.h"
Dear Computer
Please print "Hello World!" string
Then wait until user pressed a key
Best Regards
Programmer
Magic.h:
#include<stdio.h>
#include<conio.h>
#define a )
#define Best ;
#define Computer (void){
#define Dear void main
#define key ;
#define pressed (
#define Please printf
#define Programmer
#define print (
#define Regards }
#define string );
#define Then int
#define until =
#define user getch
#define wait x
|
|
|
|
|
Nice, but the following is worse, way, way , way worse. Its valid c/c++ code
??=define _i_ int
??=define _i (??/
_i_
??=include<stdio.h>
_i_ main ??/
_i ??/
__i, char* ??/
i_??/
??(??/
??))
??=define _endl_ ;
??<char _s??/
??(9??/
??), _i__??/
??(4??/
??) _endl_
??=define _s_ _endl_ _s
??<_s_ ??/
??(0??/
??) = '??/
??=' _s_ ??/
??(1??/
??) = '??/
??(' _s_ ??/
??(2??/
??) = '??/
??/??/' _endl_
??=define _m_(m_) ? m_ :
??>_s_ ??/
??(3??/
??) = '??/
??)' _s_ ??/
??(4??/
??) = '??/
??'' _s_ ??/
??(5??/
??) = '??<' _endl_
??=define _START(s) for _i __i__ = s _endl_
??<_i_ e = (__i == 2) ? (((*i_??/
??(1??/
??)-0x30) < 0) ??/
??!??/
??! ((*i_??/
??(1??/
??)-0x30) > 9)) _m_(9) (*i_??/
??(1??/
??)-0x30): 9 _endl_
??=define _VALIDATE(v) __i__ < e _endl_ __i__++)
??<_s_ ??/
??(6??/
??) = '??/
??!' _s_ ??/
??(7??/
??) = '??/
??>' _s_ ??/
??(8??/
??) = '??-' _endl_
??>
??=define move_to(n) case n:
??<_START(0) _VALIDATE(0)
??=define skip ) _endl_ break _endl_
??<switch (__i__)
??< move_to(0)
??=define to_mem sprintf (_i__,
??<to_mem "??/
???/?=" skip
??> move_to(1)
??=define _do_i_ "%d. "
??< to_mem "??/
???/?(" skip
??>move_to(2)
??< to_mem "??/
???/?/" skip
??> move_to(3)
??< to_mem "??/
???/?)" skip
??=define move_screen printf (
??=define show_single(i) , _s ??/
??(i??/
??)
??=define _char_ " %c"
??>move_to(4)
??< to_mem "??/
???/?'" skip
??> move_to(5)
??< to_mem "??/
???/?<" skip
??=define _endl_null_ return 0 _endl_
??>move_to(6)
??< to_mem "??/
???/?!" skip
??> move_to(7)
??< to_mem "??/
???/?>" skip
??=define _text_ " %s means "
??>move_to(8)
??< to_mem "??/
???/?-" skip ??>
??>move_screen _do_i_ "_text_"_text_"_char_"_char_"??/
??/n", __i__, _i__ show_single (__i__)) _endl_
??>
??>
??> _endl_null_
??>
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
|
What did I do wrong
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
BadKarma wrote: What did I do wrong
I was talking about those tri/digraphs or whatever they call them (so 80's!)
|
|
|
|