| | |
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 | |||
![]() |
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
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.
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.
•
•
Join Date: Jul 2006
Posts: 65
Reputation:
Solved Threads: 14
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.
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?"
out of this stony rubbish?"
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!
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?
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*
•
•
•
•
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.
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 "and" 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.
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.
The C compiler that comes with Dev-CPP must be more modern ...
Turbo C??? I thought that was pretty bad 20 years ago!
C++ Syntax (Toggle Plain Text)
// using "and" and "or" rather than "&&" and "||" // as a Dev-Cpp C project #include <stdio.h> #include <iso646.h> // yes this is needed! int main() { int loud, annoying, whiny; int voice = 1; loud = annoying = whiny = 1; if (voice==loud or voice==annoying and voice==whiny) { printf("SHUT UP!\n"); //cout<<"SHUT UP!"<<endl; } getchar(); return 0; }
Last edited by vegaseat; Oct 16th, 2006 at 4:30 pm.
May 'the Google' be with you!
![]() |
Other Threads in the C++ Forum
- Previous Thread: I dont know what mistake I did
- Next Thread: Passing parameters
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






