No storage class may be specified (Objective-c ) error

Discussion in 'iOS Programming' started by Avicenna, Jul 6, 2011.

  1. Avicenna, Jul 6, 2011
    Last edited: Jul 6, 2011

    macrumors member

    Joined:
    Jul 16, 2009
    #1
    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.
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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.
     
  3. thread starter macrumors member

    Joined:
    Jul 16, 2009
    #3
    Alright. Updated my original post, please check it out.
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    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.
     
  5. chown33, Jul 6, 2011
    Last edited: Jul 6, 2011

    macrumors 603

    Joined:
    Aug 9, 2009
    #5
    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.
     
  6. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #6
    Just in case anyone is ever interested, the XCode 4 equivalent is Product > Generate Output > Generate Preprocessed File
     
  7. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #7
    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.
     
  8. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #8
    Ahh, oops. Never mind. I never said anything. ;)
     

Share This Page