简体   繁体   中英

c - *(void **) &(int[2]){0,PAGE_SIZE}; meaning?

Context

Reading some kernel code.

Problem

I cannot get my head on what this line is meaning

*(void **) &(int[2]){0,PAGE_SIZE};

and more, what does this means

{0,PAGE_SIZE}

To me it doesn't look like a function with that comma.

What could be going on with this code ? I don't understand the indirections here.

Is it a function or a cast ? What does the bracket part means ? Seems so convoluted to me but definitely has a meaning.

(int[2]) { 0, PAGE_SIZE }

is an expression (called compound literal ) whose value is an array of two int s. The address of this array is taken, casted to void ** , and dereferenced.

The net result is a reinterpretation of the array contents as a pointer to void.

Note that you can take the address of a compound literal, as they are lvalues. See eg. this question .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM