Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: for Turbo C ? Message-ID: <11295@smoke.BRL.MIL> Date: 16 Oct 89 03:46:18 GMT References: <5940011@hpcupt1.HP.COM> <5940012@hpcupt1.HP.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 78 In article <5940012@hpcupt1.HP.COM> swh@hpcupt1.HP.COM (Steve Harrold) writes: >Even though the file has definitions for "va_start", "va_arg", >and so on, these definitions are not the same as found in the >file. That's right. facilities were based on traditional , with some adjustments deemed to be necessary in some potential implementation environments: variadic functions require special ,... declaration syntax so the compiler can give them special linkage if necessary va_alist and va_dcl are replaced by the ,... style function header va_start() is given a fixed argument as a "handle" to allow the implementation to know where the variadic arguments are va_list may be, but is not required to be, an array type >Even though the files are short, the #defines are rather convoluted, >rather reminiscent of APL style coding. That's okay, you shouldn't be looking at them. >Rather than spend the time to study how stacks are created and manipulated >by the Turbo C compiler and then to produce a reliable "port" of Turbo C's > file to (including the labor of creating test >cases), I've always resorted to dropping Turbo C for Microsoft C whenever >I handle source code that uses . >I'm still hopeful that some kind soul will step forward with a solution. I already suggested a solution, namely, convert the code to use the equivalent facilities. Here is a typical example of code that works with either implementation: /* typical declaration, e.g. in a package interface header: */ #ifdef __STDC__ extern void ErPrintf( const char *, ... ); #else extern void ErPrintf(); #endif /* typical definition: */ #ifdef __STDC__ #include #else #include #endif #ifdef __STDC__ void ErPrintf( const char *format, ... ) #else /*VARARGS*/ void ErPrintf( va_alist ) va_dcl #endif { #ifndef __STDC__ register const char *format; #endif va_list ap; #ifdef __STDC__ va_start( ap, format ); #else va_start( ap ); format = va_arg( ap, const char * ); #endif (void)vfprintf( stderr, format, ap ); (void)fflush( stderr ); va_end( ap ); }