This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

error C127: invalid storage class

Hello!

I have transfered my project from uVision to uVision2. The IDE has the compiler C51 V7.06 and the linker BL51 V5.03.

If I rebuilt my target, the compiler displays an error-message for all functions.
This occurs, even if a library function is used.

"error C127: invalid storage class"


The error-list contains an explanation, which I do not understand:


"An object was declared with an invalid
memory space specification. This occurs
if an object is declared with storage-
class of auto or register outside of a
function."


I dont know, why these error is created, because of I included the command "#pragma LARGE" and set even "Options for target" to "LARGE memory model". "Off Chip Xdata
memory" is set to 64k.


My project has the following structure (shortend). There could be parameters too.

// header-file: test.h

    // declaration of test()
    extern  void  test( void );


// main-file: main.c

    #pragma  LARGE

    // include header-file
    #include "test.h"

    void main( void )
    {
         // call test()
         test();
    }


// source-file: test.c

    #pragma LARGE

    void test( void )
    {
         // test source code
    }

Of course, I modified my program, but I didnt turn it free from these bug. Under uVision it works without errors.

Thank you for reply!

Parents
  • Thank you for your reply.

    Of course, the error-messages includes the name of the file and the line number.
    In detail, for each declaration of a function within the header-file, this error is created.

    I will show you four examples. The german lines are only comments:

    header-file: "smotor.h"

    
    // Bewegungsrichtung des Schrittmotors vorgeben
    extern  unsigned char   setProbeDirection( const  unsigned char  direction );
    
    // Drehgeschwindigkeit des Schrittmotors vorgeben
    extern  unsigned char   setProbeSpeed( const  unsigned char  speed );
    
    // Periodendauer als vielfaches von 5ms einstellen für den Timer
    extern  void  setImpulseTime( const  unsigned int  dauer );
    
    // Motor ein- oder ausschalten - _CLOCK wird bei aktivem Timer generiert
    extern  unsigned char   setMotor( const  unsigned char  run_motor );
    
    

    While rebuilding, the compiler shows the following messages:


    SMOTOR.H(71): error C127: '_setProbeDirection': invalid storage class
    SMOTOR.H(74): error C127: '_setProbeSpeed': invalid storage class
    SMOTOR.H(77): error C127: '_setImpulseTime': invalid storage class
    SMOTOR.H(80): error C127: '_setMotor': invalid storage class

Reply
  • Thank you for your reply.

    Of course, the error-messages includes the name of the file and the line number.
    In detail, for each declaration of a function within the header-file, this error is created.

    I will show you four examples. The german lines are only comments:

    header-file: "smotor.h"

    
    // Bewegungsrichtung des Schrittmotors vorgeben
    extern  unsigned char   setProbeDirection( const  unsigned char  direction );
    
    // Drehgeschwindigkeit des Schrittmotors vorgeben
    extern  unsigned char   setProbeSpeed( const  unsigned char  speed );
    
    // Periodendauer als vielfaches von 5ms einstellen für den Timer
    extern  void  setImpulseTime( const  unsigned int  dauer );
    
    // Motor ein- oder ausschalten - _CLOCK wird bei aktivem Timer generiert
    extern  unsigned char   setMotor( const  unsigned char  run_motor );
    
    

    While rebuilding, the compiler shows the following messages:


    SMOTOR.H(71): error C127: '_setProbeDirection': invalid storage class
    SMOTOR.H(74): error C127: '_setProbeSpeed': invalid storage class
    SMOTOR.H(77): error C127: '_setImpulseTime': invalid storage class
    SMOTOR.H(80): error C127: '_setMotor': invalid storage class

Children
  • This is a strange error, as I don't really see what 'storage class' has to do with 'memory space'. Auto and register cannot be used outwith local variables (and parameter declarations in the case of register) in any case.

    Can you cut your program down to a main function which calls one function in another file and a header file containing the appropriate prototype, then post all the code if you still get this error?

    Stefan

  • Incidentally, I've had various weird things happen when upgrading versions. Sometimes the only cure is to create a new project from scratch.

    Stefan

  • In detail, for each declaration of a function within the header-file, this error is created.

    Hmm... you haven't by any chance inadvertantly added the header files to the project as source files, have you?

    If that's not it, I think a small, but self-sufficient example case will be needed, along with the actual compiler output you get (including all options, as found in the first few lines of the *.lst file).