Cdecl – Turns English phrases into C declarations
11–20 of 56 posts
Re: Cdecl – Turns English phrases into C declarations
#12Re: Cdecl – Turns English phrases into C declarations
#13It used to be a shared host with a PHP script shelling out to the cdecl executable, written in K&R C. Now it's that same executable running on AWS Lambda.
Yes Lambda really will run arbitrary ELF binaries.
Re: Cdecl – Turns English phrases into C declarations
#14 int *pi;
Means that when I dereference the variable pi, I get an int. This also explains why int *pi, i;
declares `pi` as a pointer to `int` and `i` as an `int`. From this point of view it makes sense stylistically to put * near the variable.Declaration of array types is similar. For example,
int arr[10];
means that when I take an element of `arr`, I obtain an `int`. Hence, `arr` is an array of ints.Pointers to functions work the same way. For example,
int (*f)(char, double);
means that if I dereference the variable `f` and I evaluate it on a `char` and on a `double`, then I get an `int`. Hence, the type of `f` is "pointer to function which takes as arguments a char and a double and returns an int".Re: Cdecl – Turns English phrases into C declarations
#15Re: Cdecl – Turns English phrases into C declarations
#16Re: Cdecl – Turns English phrases into C declarations
#17Its better to create a series of typedef and build up the declaration. Most of the time you need those sub typedef anyway.
Re: Cdecl – Turns English phrases into C declarations
#18got: bad character '"'...apostrophe instead of double quote has the same result...well, I guess I expected too much
Re: Cdecl – Turns English phrases into C declarations
#19Here's an easy way to understand how these things work: in C, the type of a pointer/function/array mess is declared by how it's used. For a declaration like "int ( * ( * foo)(void))[3]", you can read it as "for a variable foo, after computing the expression ( * ( * foo)(void))[3], the result is an int." So one way to read C "gibberish" is to ignore the type at the beginning and parse the rest as an expression like a…