Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interesting C struct syntax/type

Tags:

c

struct

I came across this in the Python interpreter source code.

void
PyThread_delete_key_value(int key)
{
    long id = PyThread_get_thread_ident();
    struct key *p, **q;

The interesting part being the struct key *p, **q; call. What exactly is this structure doing? I'm confused as to what exactly this is a struct of. Is this not the same as say, this?

struct 1 *p;

I are confused.

Edit:

Even though this has been answered, I should clear up my question. It was specifically the fact that the word key was reused and that I didn't know that the compiler considers them in different namespaces.

like image 391
Falmarri Avatar asked Jul 26 '26 07:07

Falmarri


1 Answers

key exists in two different namespaces here. Once as a variable, once as a structure. The compiler knows that 'struct key' and int key are different things.

like image 72
Seth Robertson Avatar answered Jul 28 '26 21:07

Seth Robertson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!