Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7763473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:40:05+00:00 2026-06-01T14:40:05+00:00

typedef struct _ut_slot { ucontext_t uc; …. }*ut_slot; static ut_slot* table; //array of the

  • 0
typedef struct _ut_slot {
   ucontext_t uc;
   ....
}*ut_slot;

static ut_slot*  table;  //array of the structs

void foo (int tab_size){
     table =  malloc ( tab_size *(sizeof (ut_slot))); // memory allocation for array of structs 
     for(i = 0 ; i < tab_size ; i++  ){
        getcontext(&table[i].uc); <--- ?????? 
      }
}

I receive error in “getcontext” string. How can I write reference to any element of the array? And how can I initialize with “getcontext” command the “uc” field of each array element?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:40:06+00:00Added an answer on June 1, 2026 at 2:40 pm

    You have an inconsistency with the definition of ut_slot and the use of it:

    typedef struct _ut_slot {
       ucontext_t uc;
       ....
    }*ut_slot; //<--- pointer to struct
    

    You say that ut_slot is a pointer to a struct, then you declare

    static ut_slot* table;

    so you have a pointer-to-pointer-to-struct.

    You probably want ut_slot to just be a struct, or table to be a pointer-to-struct.


    To be more precise: table is a pointer-to-pointer-to-struct, so table[i] is a pointer-to-struct, and you try to access a struct member of a non-struct with table[i].ut, which raises a compilation error.


    Try the following:

    typedef struct _ut_slot {
       ucontext_t uc;
       ....
    } ut_slot; //removed "*"
    
    static ut_slot *table;
    

    the rest of your code is okay and doesn’t need to be changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these structs: typedef struct _Frag{ struct _Frag *next; char *seq; int x1;
typedef struct foo { bool my_bool; int my_int; } foo; In the example above
typedef struct stack{ int size; int array[30]; }STACK; int p; STACK *W; What is
typedef struct Value{ int id; char type; char a; } Value; void fooV(Value v){
typedef struct unit_class_struct { char *name; char *last_name; } person; int setName(person *array) {
typedef struct { int A; int B; char* C; // problem is here }foo;
//CHILD typedef struct Child{ int id; }Child; Child* newChild(){ Child *aChild = malloc(sizeof(Child)); aChild->id
typedef struct _protocol1 { int type; CGPoint pos; } Protocol1; -(void)sendData { NSError *error;
typedef struct vertex{ int num; struct vertex *next; } Vertex; Vertex *adj[1]; void buildList(){
typedef struct node { struct node *leftChild, *rightChild; int value; } bst; void insert(bst*

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.