0
error:- expected ';' at the end of the declaration list
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    float number;                   error:- expected ';' at the end of the declaration list
    float result;
    int currentoperation;
    __weak IBOutlet UILabel *label;
}

- (IBAction)canceloperation:(id)sender;
- (IBAction)cancelnumber:(id)sender;
- (IBAction)buttonoperation:(id)sender;
- (IBAction)buttonnumber:(id)sender;


@end

Please fix this code.

Mat
  • 202,337
  • 40
  • 393
  • 406
thejustv
  • 2,009
  • 26
  • 42
  • 3
    We don't "Please fix this code" here. We expect a bit of effort out of you, try asking a question instead. – Brad Koch Jun 08 '13 at 13:25
  • Have you tried searching? How about [Error: Expected ; at end of declaration list - Class not recognized as type](http://stackoverflow.com/questions/14365116/error-expected-at-end-of-declaration-list-class-not-recognized-as-type)? Or any of the "Related" questions on the right >> – Brad Koch Jun 08 '13 at 13:29
  • possible duplicate of [error: expected specifier-qualifier-list before...in Objective C?](http://stackoverflow.com/questions/1246509/error-expected-specifier-qualifier-list-before-in-objective-c) – bbum Jun 08 '13 at 18:31

2 Answers2

25

The OP's question is stated quite bad, but there is a genuine problem here.

The problem occurs when Xcode C Language Dialect is set to C99 instead of GNU99. C99 does not have a declaration for typeof(), and will assume it returns int. Then, the following bunch of confusing error messages are logged:

warning: type specifier missing, defaults to 'int'
  __weak typeof(self) weakSelf = self;
  ~~~~~~ ^
'__weak' only applies to Objective-C object or block pointer types; type here is 'int'
  __weak typeof(self) weakSelf = self;
  ^
a parameter list without types is only allowed in a function definition
  __weak typeof(self) weakSelf = self;
                ^
expected ';' at end of declaration
  __weak typeof(self) weakSelf = self;
                     ^

To change this: open the Project Navigator > click the project > click the target > Select the C Language Dialect > Hit backspace to set the default value.

enter image description here

Berik
  • 7,816
  • 2
  • 32
  • 40
  • 1
    Thanks for this, Berik. I'm working on a project that was initially started in 2009 and added a library that was having this problem. Your answer worked perfectly for me. – Stateful Aug 11 '14 at 01:41
  • 1
    I had the same issue with C99 setting, Compiler Default works fine for me. – valdyr Dec 19 '14 at 11:13
  • 1
    Thanks, worked with unity and there was such a problem. – Nike Kov Jul 01 '16 at 09:27
-3

This is a duplicate of the many "invisible character" questions. You have an invisible character in your code.

If you have a history of using emacs or using the ctrl key, you could easily have tapped ctrl-return and inserted an invisible character.

http://www.friday.com/bbum/2012/12/23/xcode-sometimes-a-return-is-not-a-return-emacs-brain-damage/

bbum
  • 162,346
  • 23
  • 271
  • 359