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 7491619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:05:21+00:00 2026-05-29T16:05:21+00:00

typedef struct _wax_instance_userdata { id instance; BOOL isClass; Class isSuper; BOOL actAsSuper; } wax_instance_userdata;

  • 0
typedef struct _wax_instance_userdata {
    id instance;
    BOOL isClass;
    Class isSuper; 
    BOOL actAsSuper; 
} wax_instance_userdata;

https://github.com/probablycorey/wax/blob/master/lib/wax_helpers.m#L497

void* afunc(){ // the function is too long
    void *value = nil;
    // ...
    wax_instance_userdata *instanceUserdata = (wax_instance_userdata *)luaL_checkudata(L, stackIndex, WAX_INSTANCE_METATABLE_NAME);

    instance = instanceUserdata->instance;

    *(id *)value = instance;
    return value;
}

https://github.com/probablycorey/wax/blob/master/lib/wax.m#L243

id* ret = afunc(); //same without this * .
id lastValue = *(id*)ret;
//now I can use lastValue;

Why need do this ?
I can’t understand the *(id*)
also the id* ret = afunc() ,when delete this star , it also works well.

  • 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-05-29T16:05:22+00:00Added an answer on May 29, 2026 at 4:05 pm

    afunc is referencing the function (void *)wax_copyToObjc(…). The intent of this function is to translate a Lua object into a C or Objective-C value. Because it could be a primitive type or an objective-c instance it doesn’t know what it is going to return. So always returns a pointer to void (meaning a pointer to something unknown). In the case of an id, it will return a pointer to an id.

    It might be easier to explain what is happening with an int, it will alloc space for the int and copy the its value:

    value = calloc(sizeof(int), 1)
    *(int *)value = lua_tointeger(L, stackIndex)
    

    (int *)value is translates to “value is a pointer to an int”
    adding the * in front of it like *(int *)value translates to “copy the int to the alloc’d memory that value points to.”

    In your example:

    id *ret = afunc(); // returns a pointer to an id
    id lastValue = *(id*)ret; // dereferences the pointer to id so it is just an id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

typedef struct foo { bool my_bool; int my_int; } foo; In the example above
typedef struct { int data1; float data2; } packetType1; typedef struct { bool data1;
typedef struct fred { char mytype[41]; char* myremark; } fred_t; With an instance of
I have this code typedef struct { const char* fooString; const bool fooBool; }fooStruct;
typedef struct { nat id; char *data; } element_struct; typedef element_struct * element; void
Consider the following: typedef struct { int a; int b; int c; int d;
I have these structs: typedef struct _Frag{ struct _Frag *next; char *seq; int x1;
Ok so I have struct like this typedef struct { float x; float y;
I have a struct like this typedef struct bookStruct { char title[80]; char author[80];
I have the following struct in C++: #define MAXCHARS 15 typedef struct { char

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.