Board index » cppbuilder » if-statement scope
Andreas Hausladen
![]() CBuilder Developer |
if-statement scope2005-09-13 01:36:30 AM cppbuilder23 I the this (simplified) code which compiles with gcc but not with bcc32 because "value" is redefined in the "else-if" part. Is there an easy way to make the if-scope working as in gcc? Renaming the variable is a solution but one that means lot's of work for me because the code (Qt4) contains many of these constructs. int getX() { return 10; } int main() { int x = getX(); if (int value = 10 - x) { // Earlier declaration of 'value' cout << value << endl; } else if (double value = 11.2 - x) { // Multiple declaration for 'value' cout << value << endl; } return 0; } -- Regards, Andreas Hausladen (andy.jgknet.de/blog) |