Weird Stuff about Dev-C++ Compiler

Please support our C++ advertiser: Intel Parallel Studio Home
View Poll Results: What do you think of this compiler abnormality?
Good Thing 4 80.00%
Bad Thing 1 20.00%
Voters: 5. You may not vote on this poll

Reply

Join Date: Oct 2006
Posts: 143
Reputation: venomlash is an unknown quantity at this point 
Solved Threads: 2
venomlash's Avatar
venomlash venomlash is offline Offline
Junior Poster

Weird Stuff about Dev-C++ Compiler

 
0
  #1
Oct 15th, 2006
I use Bloodshed Dev-C++ version 4.9.9.2 and it is a little weird in that it accepts "and" as "&&" and "or" as "||", not to mention not requiring parentheses around separate clauses in and/or connected statements. Therefore it would read the following as the same.

if(voice==loud or voice==annoying and voice==whiny){
cout<<"SHUT UP!"<<endl;
}

if((voice==loud) || ((voice==annoying) && (voice==whiny))){
cout<<"SHUT UP!"<<endl;
}

Strange, huh?
Venomlash
Beware of the Rancor. I'm not kidding.
If it doesn't compile, try saying "By the power of MegaMan!!!" <this has kinda worked for me, actually...>
Scotland is NOT North Britain, Glasgow does NOT rhyme with "cow", and Robbie Burns is...well, if you don't already know who he was, you're kinda screwed.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 65
Reputation: GloriousEremite will become famous soon enough GloriousEremite will become famous soon enough 
Solved Threads: 14
GloriousEremite GloriousEremite is offline Offline
Junior Poster in Training

Re: Weird Stuff about Dev-C++ Compiler

 
2
  #2
Oct 15th, 2006
It's not an "abnormality," it's actually part of the C++ standard. As I understand it, operators like 'and' and 'or' are included for users with different character sets. See: http://david.tribble.com/text/cdiffs.htm#C99-alt-tok

Microsoft compilers appear to implement these as macros instead of keywords in the ciso646 header.

As for the second part of your post, the equality operator takes precedence over logical AND, which takes precendence over logical OR, so the parentheses aren't required in either case.
"What are the roots that clutch, what branches grow
out of this stony rubbish?"
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Weird Stuff about Dev-C++ Compiler

 
-1
  #3
Oct 16th, 2006
Best stick with && instead of "and" as you'll encounter problems if you switch compilers.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,022
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 932
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Weird Stuff about Dev-C++ Compiler

 
0
  #4
Oct 16th, 2006
Originally Posted by iamthwee View Post
Best stick with && instead of "and" as you'll encounter problems if you switch compilers.
Again, it depends on which country you live in. Not all keyboards have a & key!!!! Actually "and" looks a lot more readable than "&&". Dev-C++ uses a much more international open source GNU compiler. Thank you GloriousEremite for the reference site!
Last edited by vegaseat; Oct 16th, 2006 at 3:04 pm.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Weird Stuff about Dev-C++ Compiler

 
0
  #5
Oct 16th, 2006
I think he does have the & key. So therefore he should use it -if he wants to guarantee better portability.

If not I would expect him to have a little note saying, if you intend to use this code with such and such a compiler please include the relevant header.

>Not all keyboards have a & key!!!!
Can't ya just hold down [alt] + ### or whatever the number is for an ampersand?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,617
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Weird Stuff about Dev-C++ Compiler

 
0
  #6
Oct 16th, 2006
Originally Posted by vegaseat View Post
Again, it depends on which country you live in. Not all keyboards have a & key!!!! Actually &quot;and&quot; looks a lot more readable than &quot;&&&quot;. Dev-C++ uses a much more international open source GNU compiler.
As expected from a Python proponent But seriously, i agree with Mr. Iamthwee, its would be better NOT to use such keywords which are fully integrated in C++ standards but require the inclusion of a seperate header file #include <iso646.h>. So if you want your C++ code to be compatible with C standards, better stick to the && operator.
C90 does not have these built-in keywords, but it does provide a standard header file that contains definitions for the same words as macros, behaving almost like built-in keywords. The recommended practice for code intended to be compiled as both C and C++ is to use &quot;and&quot; identifiers only for special meanings, and only after including the header <iso646.h> .
Last edited by ~s.o.s~; Oct 16th, 2006 at 3:23 pm.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,407
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1467
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Weird Stuff about Dev-C++ Compiler

 
0
  #7
Oct 16th, 2006
ios646.h is apparently available in the C99 C standards. But I don't know how many compilers have implement those new C standards yet.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,617
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Weird Stuff about Dev-C++ Compiler

 
0
  #8
Oct 16th, 2006
Originally Posted by Ancient Dragon View Post
ios646.h is apparently available in the C99 C standards. But I don't know how many compilers have implement those new C standards yet.
I use Code::Blocks IDE which comes packed with the GCC Mingw compiler and the C File created in it does not recognize the C++ keywords.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Weird Stuff about Dev-C++ Compiler

 
0
  #9
Oct 16th, 2006
I use turbo c which crashes most of the time.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,022
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 932
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Weird Stuff about Dev-C++ Compiler

 
0
  #10
Oct 16th, 2006
The C compiler that comes with Dev-CPP must be more modern ...
  1. // using "and" and "or" rather than "&&" and "||"
  2. // as a Dev-Cpp C project
  3.  
  4. #include <stdio.h>
  5. #include <iso646.h> // yes this is needed!
  6.  
  7. int main()
  8. {
  9. int loud, annoying, whiny;
  10. int voice = 1;
  11.  
  12. loud = annoying = whiny = 1;
  13.  
  14. if (voice==loud or voice==annoying and voice==whiny)
  15. {
  16. printf("SHUT UP!\n");
  17. //cout<<"SHUT UP!"<<endl;
  18. }
  19. getchar();
  20. return 0;
  21. }
Turbo C??? I thought that was pretty bad 20 years ago!
Last edited by vegaseat; Oct 16th, 2006 at 4:30 pm.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC