home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 241,427 of 243,242   
   Ben Bacarisse to Kaz Kylheku   
   Re: New and improved version of cdecl   
   23 Oct 25 15:05:05   
   
   From: ben@bsb.me.uk   
      
   Kaz Kylheku <643-408-1753@kylheku.com> writes:   
      
   > On 2025-10-23, Ben Bacarisse  wrote:   
   >> Thiago Adams  writes:   
   >>   
   >>> 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 .   
   >>>   
   >>> This one does not work:   
   >>>   
   >>> void (*f(int i))(void)   
   >>   
   >> Right.  But the new version Keith was posting about does work with that   
   >> declaration.   
   >   
   > A cdecl in Unbuntu, accompanied by a 1996 dated man page, handles this:   
   >   
   >   cdecl> explain void (*signal(int, void (*)(int)))(int);   
   >   declare signal as function (int, pointer to function (int) returning void)   
   >   returning pointer to function (int) returning void   
   >   
   > But chokes if we add parameter names to the function being declared:   
   >   
   >   cdecl> explain void (*signal(int sig, void (*)(int)))(int);   
   >   syntax error   
   >   cdecl> explain void (*signal(int, void (*handler)(int)))(int);   
   >   syntax error   
      
   Thanks.  Yes, it seems it's having "int i" rather than "int" that causes   
   the issue.   
      
   > Or to the function pointer being passed in:   
   >   
   >   cdecl> explain void (*signal(int, void (*)(int sig)))(int);   
   >   syntax error   
   >   
   > Or to the one being returned:   
   >   
   >   cdecl> explain void (*signal(int, void (*)(int)))(int sig);   
   >   syntax error   
   >   
   > I'm astonished that every cdecl out there would not have cases   
   > covering this: function with a function pointer param, returning   
   > a function pointer param, with and without param names.   
      
   Indeed.  Although declarations might often omit the parameter names, if   
   you copy and paste from a function definition the names with be there!   
      
   --   
   Ben.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca