Skip to content

Instantly share code, notes, and snippets.

@frankie-yanfeng
Created January 10, 2020 03:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankie-yanfeng/b88715e740163149cc5c2f3e8971f753 to your computer and use it in GitHub Desktop.
Save frankie-yanfeng/b88715e740163149cc5c2f3e8971f753 to your computer and use it in GitHub Desktop.
One implementation of stdarg.h
/* stdarg.h standard header */
#ifndef _STDARG
#define _STDARG
/* type definitions */
typedef char *va_list;
/* macros */
#define va_arg(ap, T) \
(* (T *)(((ap) += _Bnd(T, 3U)) - _Bnd(T, 3U)))
#define va_end(ap) (void)0
#define va_start(ap, A) \
(void)((ap) = (char *)&(A) + _Bnd(A, 3U))
#define _Bnd(X, bnd) (sizeof (X) + (bnd) & ~(bnd))
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment