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 243,194 of 243,242    |
|    Janis Papanagnou to David Brown    |
|    Re: printf and time_t    |
|    08 Feb 26 21:51:01    |
   
   From: janis_papanagnou+ng@hotmail.com   
      
   On 2026-02-08 18:55, David Brown wrote:   
   > On 08/02/2026 17:50, Waldek Hebisch wrote:   
   >>   
   >> Well, some important interfaces depend on varargs functions. And   
   >> while you may handle such cases via user-written wrappers, it is   
   >> much nicer if FFI machinery handles varargs.   
   >   
   > There are only a few standard C functions that are variadic, but they   
   > are quite important ones (with the *printf family at the top).   
      
   Hmm.. - if I'm thinking of using "C" standard library functions from   
   other languages the 'printf' (or 'scanf') family would be the least   
   I'd be thinking of; I/O can typically be found natively in languages,   
   and these ("unsafe") "C" functions I'd not really consider a paragon   
   to abstain from a direct, type-safe, safe, and efficient use of any   
   native function. - So I'd not call these "C"-functions "important"   
   (from the perspective of the respective native language).   
      
   I was seeking for other variadic standard "C" functions but didn't   
   find (m)any.   
      
   Where do we need variadic functions? Functions like printf/scanf which   
   are costly (due to the additional format interpretation), or (as found   
   in other languages) things like min/max which are homogeneous in types   
   and are certainly better represented by arrays.   
      
   I seem to recall we used varargs in the early 1990's in context of a   
   logging framework, but that was all. Were do folks here use them for?   
   I'm really curious to hear where they're are actually used in projects.   
      
   > But   
   > there is little doubt that C's handling of variadic functions is very   
   > unsafe, and implementations are often challenging (the SysV ABI for   
   > x86-64 is awkward and complex for variadic functions - the Win64 ABI is   
   > easier for variadics at the expense of making many other function calls   
   > less efficient). It is a weak point in the design of C.   
   >   
   > And for other languages trying to access C code via a FFI, variadic   
   > functions are going to be inefficient, complicated, and unsafe (unless   
   > you are /very/ sure of the calling parameters). If your alternative   
   > language is safer, neater, or easier to write than C (and if it isn't,   
   > why bother with it?), you'll want a better way to handle formatted   
   > printing than C's printf.   
      
   Indeed.   
      
   Janis   
      
   --- 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