Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Avicenna

macrumors member
Original poster
Jul 16, 2009
89
0
Hi,
I have been trying to figure out this error for the past 3 days. Simply don't understand what's wrong. I get this error with my Utilities.h class:


Code:
error: no type or storage class may be specified here before 'interface'

I posted this in more detail in stackoverflow but it was no help either. Please check it out : http://stackoverflow.com/questions/6590560/no-storage-class-may-be-specified-objective-c-error


Here's the .h file for Utilities:

Code:
#import <Foundation/Foundation.h>

@interface Utilities : NSObject {

}

+ (NSString *)getDocumentsDirectory;
+ (void)showActivityIndicator;
+ (void)hideActivityIndicator;
+ (void)setUser:(NSString *)userName withPassword:(NSString *)password;
+ (NSString *)getUserName;
+ (NSString *)getPassword;
+ (long long)generateTicketNumber;
+ (BOOL)reachable;
+ (NSString *)printerAddress;
+ (NSInteger)port;
+ (void)setAddress:(NSString*)newAddress andPort:(NSInteger)newPort;
+ (void)showDataActivity;



@end

I reduced the .m file to a mere:
Code:
#import "Utilities.h"

@implementation Utilities

@end

Of course, I get warnings that the methods aren't implemented. But the error of "No type or storage..." still remains.

Thanks.
 
Last edited:
Don't post links to the same question elsewhere. Either ask it here or don't ask. Post the entire code (not a screenshot, copy and paste) for your .h file.
 
Don't post links to the same question elsewhere. Either ask it here or don't ask. Post the entire code (not a screenshot, copy and paste) for your .h file.
Alright. Updated my original post, please check it out.
 
I have tried creating a new Command Line Foundation tool and added your Utilities to it via copy and paste. I get no such error. I suspect you have a non-printable character that has meaning or something similar. Try moving Utilities.h to a new file name and creating a new file via copy and pasting the .h you posted to this site.
 
When I copy and paste your provided source into suitable files and compile here, they compile with no errors, only the warnings about incomplete implementation of class 'Utilities'. Therefore, I suspect nothing is syntactically wrong with the posted source code.

I suspect there may be some invisible characters in your actual source file. Or perhaps you have damaged something in Foundation/Foundation.h. Or perhaps you have some unexpected search-path for #includes that is including the wrong Foundation.h.

If there are invisible characters in your actual file, we won't be able to see them simply by you pasting code into posts. You'll have to compress and upload the actual files.

Or you could use a hex editor such as Hex Fiend (google it) to inspect your source files for unexpected characters.

Depending on which Xcode version you're using (3.x would be suitable, 4.x I don't know), you can choose Build > Preprocess and inspect the result to see if there's something unexpected after the expanded #import of Foundation.h, directly before your @interface.

EDIT
Another thing occurred to me: you might have an unexpected macro expansion appearing before your @interface, triggered by what you think is an innocuous word or term, but which the preprocessor is expanding into something that doesn't compile correctly.

It's slightly odd that you're getting a specific "type or storage class" error. If there were uninterpretable invisible characters, I might expect a complaint about an unexpected character. But if the preprocessor is doing a macro substitution, and that leads to a syntax error, then the actual error isn't at the @interface, but at some location before it. If the actual source is exactly as posted, then that can only be at the end of the expanded #import of Foundation.h. However, if there is actually some other text between the #import and the @interface, then that could be causing the error and you've simply not bothered to post it because you believed it to be harmless.
 
Last edited:
Depending on which Xcode version you're using (3.x would be suitable, 4.x I don't know), you can choose Build > Preprocess and inspect the result to see if there's something unexpected after the expanded #import of Foundation.h, directly before your @interface.

Just in case anyone is ever interested, the XCode 4 equivalent is Product > Generate Output > Generate Preprocessed File
 
On what version of Xcode 4 is there a Product > Generate Output > Generate Preprocessed File menu item? I'm using 4.0.2 and I don't see that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.