lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 24 August 2015 at 04:59, Sean Conner <sean@conman.org> wrote:
> And I still have to play around with syntax when I want to use ... and I
> keep forgetting the name ... anonymous pointers?
>
>         rc = setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(int){1},sizeof(int));
>
> instead of
>
>         int opt = 1;
>         rc = setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(int));
>
> Annoying, but I live with it.
>
>   -spc

"compound literal" is the term you're looking for.
They're very useful :)

For setsockopt you'll need to take the address of your compound literal:

setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &(int){1}, sizeof(int));