• New and improved version of cdecl

    From Keith Thompson@3:633/10 to All on Wed Oct 22 14:39:43 2025
    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 */

    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Thiago Adams@3:633/10 to All on Wed Oct 22 22:19:24 2025
    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)




    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Andrey Tarasevich@3:633/10 to All on Sun Oct 26 12:09:22 2025
    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


    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Sun Oct 26 14:44:49 2025
    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...)

    [...]

    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Sun Oct 26 15:36:07 2025
    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 */

    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Sun Oct 26 15:38:18 2025
    "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 */

    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Mon Oct 27 11:51:25 2025
    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.

    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)