• New and improved version of cdecl

    From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c,comp.lang.c++ on Wed Oct 22 14:39:43 2025
    From Newsgroup: comp.lang.c++

    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 */
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Thiago Adams@thiago.adams@gmail.com to comp.lang.c,comp.lang.c++ on Wed Oct 22 22:19:24 2025
    From Newsgroup: comp.lang.c++

    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)



    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Andrey Tarasevich@noone@noone.net to comp.lang.c,comp.lang.c++ on Sun Oct 26 12:09:22 2025
    From Newsgroup: comp.lang.c++

    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

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c,comp.lang.c++ on Sun Oct 26 14:44:49 2025
    From Newsgroup: comp.lang.c++

    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...)

    [...]
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c,comp.lang.c++ on Sun Oct 26 15:36:07 2025
    From Newsgroup: comp.lang.c++

    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 */
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c,comp.lang.c++ on Sun Oct 26 15:38:18 2025
    From Newsgroup: comp.lang.c++

    "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 */
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c,comp.lang.c++ on Mon Oct 27 11:51:25 2025
    From Newsgroup: comp.lang.c++

    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.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Paul J. Lucas@paul@lucasmail.org to comp.lang.c,comp.lang.c++ on Tue Dec 9 07:31:56 2025
    From Newsgroup: comp.lang.c++

    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

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Kaz Kylheku@046-301-5902@kylheku.com to comp.lang.c,comp.lang.c++ on Tue Dec 9 20:38:58 2025
    From Newsgroup: comp.lang.c++

    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
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Paul J. Lucas@paul@lucasmail.org to comp.lang.c,comp.lang.c++ on Tue Dec 9 16:46:14 2025
    From Newsgroup: comp.lang.c++

    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
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c,comp.lang.c++ on Tue Dec 9 17:51:05 2025
    From Newsgroup: comp.lang.c++

    "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 */
    --- Synchronet 3.21a-Linux NewsLink 1.2