What does this error mean: “error: expected specifier-qualifier-list before 'type_name'”?

前端 未结 7 759
挽巷
挽巷 2020-12-05 06:09

I\'ve been working on the Cell processor and I\'m trying to create a struct that will hold an spe_context_ptr_t, which will be used within the thread to launch

相关标签:
7条回答
  • 2020-12-05 06:43

    The compiler doesn't know that spe_context_ptr_t is a type. Check that the appropriate typedef is in scope when this code is compiled. You may have forgotten to include the appropriate header file.

    0 讨论(0)
  • 2020-12-05 06:45

    I was able to sort this out using Gorgando's fix, but instead of moving imports away, I commented each out individually, built the app, then edited accordingly until I got rid of them.

    0 讨论(0)
  • 2020-12-05 06:47

    this error basically comes when you use the object before using it.

    0 讨论(0)
  • 2020-12-05 06:48

    I had the same error message but the solution is different.

    The compiler parses the file from top to bottom.

    Make sure a struct is defined BEFORE using it into another:

    typedef struct
    {
        char name[50];
        wheel_t wheels[4]; //wrong, wheel_t is not defined yet
    } car_t;
    
    typedef struct
    {
        int weight;
    } wheel_t;
    
    0 讨论(0)
  • 2020-12-05 06:49

    You have to name your struct like that:

    typedef struct car_t {
    
       char
    
       wheel_t
    
    } car_t;
    
    0 讨论(0)
  • 2020-12-05 06:54

    I got it with an import loop:

    ---FILE B.h
    #import "A.h"
    @interface B{
      A *a;
    }
    @end
    
    ---FILE A.h
    #import "B.h"
    @interface A{      
    }
    @end
    
    0 讨论(0)
提交回复
热议问题