Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #122869 > unrolled thread
| Started by | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| First post | 2025-10-22 14:39 -0700 |
| Last post | 2025-10-27 11:51 -0700 |
| Articles | 11 — 6 participants |
Back to article view | Back to comp.lang.c++
New and improved version of cdecl Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-10-22 14:39 -0700
Re: New and improved version of cdecl Thiago Adams <thiago.adams@gmail.com> - 2025-10-22 22:19 -0300
Re: New and improved version of cdecl Andrey Tarasevich <noone@noone.net> - 2025-10-26 12:09 -0700
Re: New and improved version of cdecl Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-10-26 15:36 -0700
Re: New and improved version of cdecl "Paul J. Lucas" <paul@lucasmail.org> - 2025-12-09 07:31 -0800
Re: New and improved version of cdecl Kaz Kylheku <046-301-5902@kylheku.com> - 2025-12-09 20:38 +0000
Re: New and improved version of cdecl "Paul J. Lucas" <paul@lucasmail.org> - 2025-12-09 16:46 -0800
Re: New and improved version of cdecl Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-12-09 17:51 -0800
Re: New and improved version of cdecl "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2025-10-26 14:44 -0700
Re: New and improved version of cdecl Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-10-26 15:38 -0700
Re: New and improved version of cdecl "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2025-10-27 11:51 -0700
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2025-10-22 14:39 -0700 |
| Subject | New and improved version of cdecl |
| Message-ID | <87bjlyobts.fsf@example.invalid> |
This is cross-posted to comp.lang.c and comp.lang.c++.
Consider redirecting followups as appropriate.
cdecl, along with c++decl, is a tool that translates C or C++
declaration syntax into English, and vice versa. For example :
$ cdecl
Type `help' or `?' for help
cdecl> explain const char *foo[42]
declare foo as array 42 of pointer to const char
cdecl> declare bar as pointer to function (void) returning int
int (*bar)(void )
It's also available via the web site <https://cdecl.org/>.
The original version of cdecl was posted on comp.sources.unix, probably
in the 1980s.
"ridiculous_fish" added support for Apple's blocks syntax. That
version, 2.5, is the one that's most widely available (it's provided by
the "cdecl" package on Debian and Ubuntu) and used by the cdecl.org
website.
There's a newer fork of cdecl, available in source code at
https://github.com/paul-j-lucas/cdecl/
It supports newer versions of C and C++ and adds a number of
new features. See the README.md file, visible at the above URL,
for more information. (It doesn't support Apple's block syntax.)
There doesn't seem to be a binary distribution, but the latest
source tarball is at
https://github.com/paul-j-lucas/cdecl/releases/download/cdecl-18.5/cdecl-18.5.tar.gz
It can be built on Unix-like systems with the usual "./configure;
make; make install" sequence. To build from a copy of the git repo,
run "./bootstrap" first to generate the "configure" script.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [next] | [standalone]
| From | Thiago Adams <thiago.adams@gmail.com> |
|---|---|
| Date | 2025-10-22 22:19 -0300 |
| Message-ID | <10dbvqs$12d0f$1@dont-email.me> |
| In reply to | #122869 |
Em 22/10/2025 18:39, Keith Thompson escreveu: > This is cross-posted to comp.lang.c and comp.lang.c++. > Consider redirecting followups as appropriate. > > cdecl, along with c++decl, is a tool that translates C or C++ > declaration syntax into English, and vice versa. For example : > > $ cdecl > Type `help' or `?' for help > cdecl> explain const char *foo[42] > declare foo as array 42 of pointer to const char > cdecl> declare bar as pointer to function (void) returning int > int (*bar)(void ) > > It's also available via the web site <https://cdecl.org/>. This one does not work: void (*f(int i))(void)
[toc] | [prev] | [next] | [standalone]
| From | Andrey Tarasevich <noone@noone.net> |
|---|---|
| Date | 2025-10-26 12:09 -0700 |
| Message-ID | <10dlrl2$78t1$1@dont-email.me> |
| In reply to | #122869 |
On Wed 10/22/2025 2:39 PM, Keith Thompson wrote: > ... I believe I have already posted about it here... or maybe not? cdecl.org reports a "syntax error" for declarations with top-level `const` qualifiers on function parameters: void foo(char *const) Such declarations are perfectly valid. (And adding an explcit parameter name does not help). The current version of cdecl.org still complains about it. -- Best regards, Andrey
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2025-10-26 15:36 -0700 |
| Message-ID | <87v7k1z3xk.fsf@example.invalid> |
| In reply to | #122879 |
Andrey Tarasevich <noone@noone.net> writes:
> On Wed 10/22/2025 2:39 PM, Keith Thompson wrote:
>> ...
>
> I believe I have already posted about it here... or maybe not?
>
> cdecl.org reports a "syntax error" for declarations with top-level
> `const` qualifiers on function parameters:
>
> void foo(char *const)
>
> Such declarations are perfectly valid. (And adding an explcit
> parameter name does not help).
>
> The current version of cdecl.org still complains about it.
You're probably using 2.5, the version most commonly packaged with Linux
distributions. The cdecl.org site uses that same old version.
This entire thread is about the newer version available at
<https://github.com/paul-j-lucas/cdecl/>. It doesn't have that bug.
$ cdecl --version
cdecl 18.6
Copyright (C) 2025 Paul J. Lucas
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY to the extent permitted by law.
$ cdecl explain 'void foo(char *const)'
declare foo as function (constant pointer to character) returning void
$ cdecl explain 'void foo(char *const foo)'
declare foo as function (foo as constant pointer to character) returning void
$
(I'm not entirely pleased that the newer version expands "char" to
"character" and, worse, "int" to "integer", but I can live with it.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | "Paul J. Lucas" <paul@lucasmail.org> |
|---|---|
| Date | 2025-12-09 07:31 -0800 |
| Message-ID | <10h9fde$th53$1@dont-email.me> |
| In reply to | #122881 |
On 10/26/25 3:36 PM, Keith Thompson wrote: > (I'm not entirely pleased that the newer version expands "char" to > "character" and, worse, "int" to "integer", but I can live with it.) Hence the --no-english-types or -T command line option or the "set noenglish" command (from within cdecl or a config file). The thought was that those newer to C and less familiar with its types might benefit from more elaborate output. - Paul
[toc] | [prev] | [next] | [standalone]
| From | Kaz Kylheku <046-301-5902@kylheku.com> |
|---|---|
| Date | 2025-12-09 20:38 +0000 |
| Message-ID | <20251209121945.235@kylheku.com> |
| In reply to | #123122 |
On 2025-12-09, Paul J. Lucas <paul@lucasmail.org> wrote: > On 10/26/25 3:36 PM, Keith Thompson wrote: >> (I'm not entirely pleased that the newer version expands "char" to >> "character" and, worse, "int" to "integer", but I can live with it.) > > Hence the --no-english-types or -T command line option or the > "set noenglish" command (from within cdecl or a config file). The problem is that the English words chosen already have a meaning. "Integer" is a type category in C; uint32_t is one of the "integer types". "Character" is a representational concept for units of text, manifesting itself via different types and sometimes even aggregates (e.g multi-byte character). > The thought was that those newer to C and less familiar with its > types might benefit from more elaborate output. This kind of thing just ensures that newbies go sideways from being less familiar to being incorrectly familiar. They should know from their first contact with the char type that it's just an integer type with a small range. (Arrays of which are used for text storage in classic text processing, where if a legacy character set is used such as ASCII, there is a 1:1 correspondence between each char element and a character, otherwise not.) -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca
[toc] | [prev] | [next] | [standalone]
| From | "Paul J. Lucas" <paul@lucasmail.org> |
|---|---|
| Date | 2025-12-09 16:46 -0800 |
| Message-ID | <10hafso$16u9e$1@dont-email.me> |
| In reply to | #123123 |
On 12/9/25 12:38 PM, Kaz Kylheku wrote: > On 2025-12-09, Paul J. Lucas <paul@lucasmail.org> wrote: >> On 10/26/25 3:36 PM, Keith Thompson wrote: >>> (I'm not entirely pleased that the newer version expands "char" to >>> "character" and, worse, "int" to "integer", but I can live with it.) >> >> Hence the --no-english-types or -T command line option or the >> "set noenglish" command (from within cdecl or a config file). > > The problem is that the English words chosen already have a meaning. > > "Integer" is a type category in C; It's not a keyword, so that's irrelevant. Likewise, "Character." >> The thought was that those newer to C and less familiar with its >> types might benefit from more elaborate output. > > This kind of thing just ensures that newbies go sideways from being > less familiar to being incorrectly familiar. Opinion noted. I disagree. - Paul
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2025-12-09 17:51 -0800 |
| Message-ID | <87bjk7ayuu.fsf@example.invalid> |
| In reply to | #123125 |
"Paul J. Lucas" <paul@lucasmail.org> writes:
> On 12/9/25 12:38 PM, Kaz Kylheku wrote:
>> On 2025-12-09, Paul J. Lucas <paul@lucasmail.org> wrote:
>>> On 10/26/25 3:36 PM, Keith Thompson wrote:
>>>> (I'm not entirely pleased that the newer version expands
>>>> "char" to "character" and, worse, "int" to "integer", but I
>>>> can live with it.)
>>>
>>> Hence the --no-english-types or -T command line option or the
>>> "set noenglish" command (from within cdecl or a config file).
>> The problem is that the English words chosen already have a
>> meaning. "Integer" is a type category in C;
>
> It's not a keyword, so that's irrelevant. Likewise,
> "Character."
>
>>> The thought was that those newer to C and less familiar with
>>> its types might benefit from more elaborate output.
>> This kind of thing just ensures that newbies go sideways from
>> being less familiar to being incorrectly familiar.
>
> Opinion noted. I disagree.
If you prefer the C-like syntax rather than pseudo-English (as I
do), you can change the default by creating a ".cdeclrc" file.
$ cdecl explain "int n;" declare n as integer $ echo "set
noenglish-types" > $HOME/.cdeclrc $ cdecl explain "int n;" declare
n as int $
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> |
|---|---|
| Date | 2025-10-26 14:44 -0700 |
| Message-ID | <10dm4oi$9uhq$1@dont-email.me> |
| In reply to | #122869 |
On 10/22/2025 2:39 PM, Keith Thompson wrote:
> This is cross-posted to comp.lang.c and comp.lang.c++.
> Consider redirecting followups as appropriate.
>
> cdecl, along with c++decl, is a tool that translates C or C++
> declaration syntax into English, and vice versa. For example :
>
> $ cdecl
> Type `help' or `?' for help
> cdecl> explain const char *foo[42]
> declare foo as array 42 of pointer to const char
> cdecl> declare bar as pointer to function (void) returning int
> int (*bar)(void )
>
> It's also available via the web site <https://cdecl.org/>.
I must be doing something wrong:
int (*fp_read) (void* const, void*, size_t)
is syntax error. It from one of my older experiments:
struct device_prv_vtable {
int (*fp_read) (void* const, void*, size_t);
int (*fp_write) (void* const, void const*, size_t);
};
https://groups.google.com/g/comp.lang.c/c/-BFbjYxcBQg/m/2uRErOV6AgAJ
https://pastebin.com/raw/f52a443b1
(link to raw text...)
[...]
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2025-10-26 15:38 -0700 |
| Message-ID | <87qzupz3tx.fsf@example.invalid> |
| In reply to | #122880 |
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
> On 10/22/2025 2:39 PM, Keith Thompson wrote:
>> This is cross-posted to comp.lang.c and comp.lang.c++.
>> Consider redirecting followups as appropriate.
>> cdecl, along with c++decl, is a tool that translates C or C++
>> declaration syntax into English, and vice versa. For example :
>> $ cdecl
>> Type `help' or `?' for help
>> cdecl> explain const char *foo[42]
>> declare foo as array 42 of pointer to const char
>> cdecl> declare bar as pointer to function (void) returning int
>> int (*bar)(void )
>> It's also available via the web site <https://cdecl.org/>.
> I must be doing something wrong:
Yes.
> int (*fp_read) (void* const, void*, size_t)
>
> is syntax error. It from one of my older experiments:
You're using the old 2.5 version. The newer forked version handles that
declaration correctly, but you have to build it from source. cdecl.org
uses the old version.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> |
|---|---|
| Date | 2025-10-27 11:51 -0700 |
| Message-ID | <10doeve$13cso$2@dont-email.me> |
| In reply to | #122882 |
On 10/26/2025 3:38 PM, Keith Thompson wrote: > "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes: >> On 10/22/2025 2:39 PM, Keith Thompson wrote: >>> This is cross-posted to comp.lang.c and comp.lang.c++. >>> Consider redirecting followups as appropriate. >>> cdecl, along with c++decl, is a tool that translates C or C++ >>> declaration syntax into English, and vice versa. For example : >>> $ cdecl >>> Type `help' or `?' for help >>> cdecl> explain const char *foo[42] >>> declare foo as array 42 of pointer to const char >>> cdecl> declare bar as pointer to function (void) returning int >>> int (*bar)(void ) >>> It's also available via the web site <https://cdecl.org/>. >> I must be doing something wrong: > > Yes. > >> int (*fp_read) (void* const, void*, size_t) >> >> is syntax error. It from one of my older experiments: > > You're using the old 2.5 version. The newer forked version handles that > declaration correctly, but you have to build it from source. cdecl.org > uses the old version. > Ahh! Thanks Keith.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web