See the following c code snippet located at here [1]:
typedef struct protocol {
const int default_port;
int(*const parse_packet)(const char *, size_t, char **);
} protocol_t;
In the above definition, it seems to me that the `int ...' line is difficult to understand. So I want to dig/find some clues from the extensive/exhaustive *nix man page. I'm not sure if there is a convenient way to do this.
Any hints will be highly appreciated.
[1] https://github.com/hongyi-zhao/shadowsocksr-libev/blob/1be671bd5fe7cd55d3823d4669786c9ba7913b9e/src/protocol.h#L29
Regards,
HY
See the following c code snippet located at here [1]:
typedef struct protocol {
const int default_port;
int(*const parse_packet)(const char *, size_t, char **);
} protocol_t;
In the above definition, it seems to me that the `int ...' line is difficult to
understand. So I want to dig/find some clues from the extensive/exhaustive *nix
man page. I'm not sure if there is a convenient way to do this.
See the following c code snippet located at here [1]:
typedef struct protocol {
const int default_port;
int(*const parse_packet)(const char *, size_t, char **);
} protocol_t;
In the above definition, it seems to me that the `int ...' line is difficult to understand. So I want to dig/find some clues from the extensive/exhaustive *nix man page. I'm not sure if there is a convenient way to do this.
On 31.08.21 12:33, hongy...@gmail.com wrote:
See the following c code snippet located at here [1]:
typedef struct protocol {
const int default_port;
int(*const parse_packet)(const char *, size_t, char **);
} protocol_t;
In the above definition, it seems to me that the `int ...' line is difficult to understand. So I want to dig/find some clues from the extensive/exhaustive *nix man page. I'm not sure if there is a convenient way to do this.
I'm not sure if the manual pages will be of any help here, but analyzing
this is quite simple:
1) As there is a type designator ("int") at the beginning and a list of
(what looks like) parameters at the end, this looks like a function declaration. So this is a function expecting three arguments of the
proper kind and returning an int.
2) Where there is usually a function *name*, there is a "*const
parse_packet" (put between parentheses to satisfy C's precendece rules),
so (leaving the "const" aside for a moment), "* parse_packet" is the
function "name", so "parse_packet" is the name of a pointer to the function.
3) The "const" in front of the pointer name means that this field is "constant", so, once initialialized, cannot be changed any more.
Maybe check http://unixwiz.net/techtips/reading-cdecl.html
Josef
I can vaguely recall having seen a program which takes an arbitrarily
complex variable declaration and spits out a (human readable)
description of the declaration, eg
int *a; -> "a pointer to an int"
But I can't find it atm.
In article <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>, hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
See the following c code snippet located at here [1]:
typedef struct protocol {
const int default_port;
int(*const parse_packet)(const char *, size_t, char **);
} protocol_t;
In the above definition, it seems to me that the `int ...' line is difficult to
understand. So I want to dig/find some clues from the extensive/exhaustive *nix
man page. I'm not sure if there is a convenient way to do this.
Hi!
I don't understand brain surgery. I've made a few stabs at it, but all my patients (so far) have died.
On 2021-08-31, Kenny McCormack <gazelle@shell.xmission.com> wrote:
In article <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>,
hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
See the following c code snippet located at here [1]:
typedef struct protocol {
const int default_port;
int(*const parse_packet)(const char *, size_t, char **);
} protocol_t;
In the above definition, it seems to me that the `int ...' line is difficult to
understand. So I want to dig/find some clues from the extensive/exhaustive *nix
man page. I'm not sure if there is a convenient way to do this.
Hi!
I don't understand brain surgery. I've made a few stabs at it, but all my >> patients (so far) have died.
Please post the smallest (or smallest-brained) patient before they died,
the dead version of the patient, and a description of their actual
expected behavior.
On 2021-08-31, Kenny McCormack <gazelle@shell.xmission.com> wrote:
I don't understand brain surgery. I've made a few stabs at it, but all my >> patients (so far) have died.Please post the smallest (or smallest-brained) patient before they died,
the dead version of the patient, and a description of their actual
expected behavior.
Josef Moellers <josef.moellers@invalid.invalid> writes:
I can vaguely recall having seen a program which takes an arbitrarily
complex variable declaration and spits out a (human readable)
description of the declaration, eg
int *a; -> "a pointer to an int"
But I can't find it atm.
Yes, it's called "cdecl", also available online at https://cdecl.org/
$ cdecl
Type `help' or `?' for help
cdecl> explain int(*const parse_packet)(const char *, size_t, char **); declare parse_packet as const pointer to function (pointer to const char, size_t, pointer to pointer to char) returning int
cdecl>
In comp.unix.shell, Kaz Kylheku <563-365-8930@kylheku.com> wrote:
On 2021-08-31, Kenny McCormack <gazelle@shell.xmission.com> wrote:
I don't understand brain surgery. I've made a few stabs at it, but all my >>> patients (so far) have died.Please post the smallest (or smallest-brained) patient before they died,
the dead version of the patient, and a description of their actual
expected behavior.
I don't think my Usenet privder will let me upload RFC-1437 attachments.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 74:04:30 |
Calls: | 6,657 |
Calls today: | 3 |
Files: | 12,203 |
Messages: | 5,332,501 |
Posted today: | 1 |