V
vikascoder
Consider the following code snippet..
#include<iostream>
using namespace std;
int func(void);
int main() {
cout<<"Result :"<<func()<<endl;
}
int func (void) {
int result = 0;
if (true) {
result = 1;
goto cleaup:
}
int i = 0; // i initialize a dummy here.. Error in XCode or Gcc !
cleanup:
return (result);
}
If i compile the above code with Visual Studio 6.0 compiler or
CodeWarrior (Mac) it compiles without any error, but if i compile this
code using gcc or XCode (Mac) it gives the following error..
error: jump to label 'cleanup'
error: from here
error: crosses initialization of 'int i'
The only way to solve this problem is to move the 'int i' definition
below the 'int result' definition... is there any other way??
#include<iostream>
using namespace std;
int func(void);
int main() {
cout<<"Result :"<<func()<<endl;
}
int func (void) {
int result = 0;
if (true) {
result = 1;
goto cleaup:
}
int i = 0; // i initialize a dummy here.. Error in XCode or Gcc !
cleanup:
return (result);
}
If i compile the above code with Visual Studio 6.0 compiler or
CodeWarrior (Mac) it compiles without any error, but if i compile this
code using gcc or XCode (Mac) it gives the following error..
error: jump to label 'cleanup'
error: from here
error: crosses initialization of 'int i'
The only way to solve this problem is to move the 'int i' definition
below the 'int result' definition... is there any other way??