compiler bug ?

This is a discussion on compiler bug ? within the C++ Programming forums, part of the General Programming Boards category; this section of code does not compile: if(tolower(*p1) != (tolower(*p2)) break; the error is "missing ')' before 'break' when i ...

  1. #1
    Registered User Spectrum48k's Avatar
    Join Date
    May 2002
    Posts
    66

    compiler bug ?

    this section of code does not compile:
    if(tolower(*p1) != (tolower(*p2)) break;

    the error is "missing ')' before 'break'

    when i put the bracket before 'break' it compiles !
    it shouldnt though, because the bracket is not needed,
    and it was working just fine yesterday. can it be a compiler
    bug ? i am using visual studio.
    this is how it works:

    if(tolower(*p1) != (tolower(*p2))) break;
    its alive... its ALIVE... ITS...AL...IIIVE !!!!!!!!!

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    cant u count to 3 sets of pairs?
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User Spectrum48k's Avatar
    Join Date
    May 2002
    Posts
    66
    its been a looong day dude... my eyes are playing tricks..

    thnx anyway..
    its alive... its ALIVE... ITS...AL...IIIVE !!!!!!!!!

  4. #4
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572

    Re: compiler bug ?

    Originally posted by Spectrum48k
    this section of code does not compile:
    if(tolower(*p1) != (tolower(*p2)) break;

    the error is "missing ')' before 'break'

    Why did you seperate the second condition? To make your code look good you should do with the same convention; so either write:
    Code:
    if( tolower(*p1) != tolower(*p2) ) break;
    or
    Code:
    if( (tolower(*p1) ) != (tolower(*p2) ) ) break;
    I find the second useful when doing something like this
    Code:
    if( (p1==x && p2==y) || (p3!=y) )
    where you want to seperate the conditions just for clarity.

    axon

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >can it be a compiler bug ?
    99.9 times the compiler is correct and your code is not.
    Code:
    if( tolower(*p1) != tolower(*p2) ) break;
    OPEN  1
    OPEN  2
    CLOSE 2
    OPEN  3
    OPEN  4
    CLOSE 4
    CLOSE 3
    Number one isn't closed anywhere, all compilers tend to complain about such things.

    -Prelude
    My best code is written with the delete key.

  6. #6
    Registered User Spectrum48k's Avatar
    Join Date
    May 2002
    Posts
    66
    Code:
    if(tolower(*p1) != tolower(*p2)) break;
    this is all i needed. as i said.. after 13 hours on the screen
    i am lucky i can count to 3 nevermind see the brackets not needed.

    thnx for the tips.
    its alive... its ALIVE... ITS...AL...IIIVE !!!!!!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Have you ever written a compiler?
    By ammar in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 12-27-2004, 06:10 AM
  2. Dev C++ Compiler, Indentation?
    By Zeusbwr in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2004, 06:13 AM
  3. lcc win32 compiler download problems
    By GanglyLamb in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-01-2004, 07:39 PM
  4. OpenScript2.0 Compiler
    By jverkoey in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2003, 12:52 PM
  5. Compiler or OS bug??
    By Frantic in forum C++ Programming
    Replies: 6
    Last Post: 05-20-2003, 11:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21