Skip to content

Commit

Permalink
Include stdarg.h instead of defining new types
Browse files Browse the repository at this point in the history
Windows considers new definitions of va_(list|arg|start|end|copy) syntax
errors, and instead expects stdarg.h to be included
  • Loading branch information
krx committed Jul 13, 2017
1 parent e839540 commit 3073f36
Show file tree
Hide file tree
Showing 265 changed files with 1,775 additions and 684 deletions.
4 changes: 4 additions & 0 deletions challenges/3D_Image_Toolkit/lib/cgc_stdarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ THE SOFTWARE.
#ifndef __STDARG_H__
#define __STDARG_H__

#ifdef WIN
#include <stdarg.h>
#else
typedef __builtin_va_list va_list;

#define va_start(v, l) __builtin_va_start(v, l)
#define va_arg(v, l) __builtin_va_arg(v, l)
#define va_end(v) __builtin_va_end(v)
#endif

#endif // __STDARG_H__
13 changes: 9 additions & 4 deletions challenges/AIS-Lite/lib/cgc_xxprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@


// VA defs for xxprintf functions
#ifdef WIN
#define _VA_LIST 1
#include <stdarg.h>
#else
#ifndef _VA_LIST
typedef __builtin_va_list va_list;
#define _VA_LIST 1
Expand All @@ -47,7 +51,7 @@ typedef __builtin_va_list va_list;
#define va_end(al) __builtin_va_end(al)

/**
* Expand to an expression that has the type and value of the
* Expand to an expression that has the type and value of the
* next argement in the function call.
*
* @param al Arguments list
Expand All @@ -66,6 +70,7 @@ typedef __builtin_va_list va_list;
* @param s Source variable arguments list
*/
#define va_copy(d, s) __builtin_va_copy(d, s)
#endif

/**
* A simple, non-standard vsnprintf.
Expand All @@ -82,7 +87,7 @@ typedef __builtin_va_list va_list;
* For each format specifier, it will take a value from args
* and insert it at that location as that type.
*
* Note: vsnprintf does not call va_end, because it takes a va_list,
* Note: vsnprintf does not call va_end, because it takes a va_list,
* caller does so.
*
* @param buf Output buffer
Expand All @@ -108,7 +113,7 @@ int cgc_vsnprintf(char * buf, cgc_size_t buf_size, const char * fmt, va_list arg
* For each format specifier, it will take a value from args
* and insert it at that location as that type.
*
* Note: vsnprintf does not call va_end, because it takes a va_list,
* Note: vsnprintf does not call va_end, because it takes a va_list,
* caller does so.
*
* @param buf Output buffer
Expand All @@ -119,4 +124,4 @@ int cgc_vsnprintf(char * buf, cgc_size_t buf_size, const char * fmt, va_list arg
*/
int cgc_snprintf(char * buf, cgc_size_t buf_size, const char * fmt, ...);

#endif
#endif
4 changes: 4 additions & 0 deletions challenges/ASCII_Content_Server/include/cgc_stdarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ THE SOFTWARE.
#ifndef __STDARG_H__
#define __STDARG_H__

#ifdef WIN
#include <stdarg.h>
#else
typedef __builtin_va_list __gnuc_va_list;

#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#endif

typedef __gnuc_va_list va_list;

Expand Down
4 changes: 4 additions & 0 deletions challenges/ASL6parse/lib/cgc_stdarg.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#ifndef STDARG_H_
#define STDARG_H_

#ifdef WIN
#include <stdarg.h>
#else
typedef __builtin_va_list __gnuc_va_list;
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#endif
typedef __gnuc_va_list va_list;

#endif /* !STDARG_H_ */
41 changes: 23 additions & 18 deletions challenges/A_Game_of_Chance/cb_1/lib/cgc_xxprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@


// VA defs for xxprintf functions
#ifdef WIN
#define _VA_LIST 1
#include <stdarg.h>
#else
#ifndef _VA_LIST
typedef __builtin_va_list va_list;
#define _VA_LIST 1
Expand All @@ -46,7 +50,7 @@ typedef __builtin_va_list va_list;
#define va_end(al) __builtin_va_end(al)

/**
* Expand to an expression that has the type and value of the
* Expand to an expression that has the type and value of the
* next argement in the function call.
*
* @param al Arguments list
Expand All @@ -65,6 +69,7 @@ typedef __builtin_va_list va_list;
* @param s Source variable arguments list
*/
#define va_copy(d, s) __builtin_va_copy(d, s)
#endif

/**
* A simple, non-standard vsnprintf.
Expand All @@ -76,11 +81,11 @@ typedef __builtin_va_list va_list;
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand All @@ -91,7 +96,7 @@ typedef __builtin_va_list va_list;
* For each format specifier, it will take a value from args
* and insert it at that location as that type.
*
* Note: vsnprintf does not call va_end, because it takes a va_list,
* Note: vsnprintf does not call va_end, because it takes a va_list,
* caller does so.
*
* @param buf Output buffer
Expand All @@ -114,11 +119,11 @@ int vsnprintf(char * buf, cgc_size_t buf_size, const char fsm, const char term,
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand Down Expand Up @@ -149,11 +154,11 @@ int snprintf(char * buf, cgc_size_t buf_size, const char fsm, const char term, c
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand All @@ -164,7 +169,7 @@ int snprintf(char * buf, cgc_size_t buf_size, const char fsm, const char term, c
* For each format specifier, it will take a value from args
* and insert it at that location as that type.
*
* Note: vfdprintf does not call va_end, because it takes a va_list,
* Note: vfdprintf does not call va_end, because it takes a va_list,
* caller does so.
*
* @param fd file descriptor to cgc_write to
Expand All @@ -186,11 +191,11 @@ int vfdprintf(int fd, const char fsm, const char term, const char *fmt, va_list
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand Down Expand Up @@ -220,11 +225,11 @@ int fdprintf(int fd, const char fsm, const char term, const char *fmt, ...);
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand Down
41 changes: 23 additions & 18 deletions challenges/A_Game_of_Chance/cb_2/lib/cgc_xxprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@


// VA defs for xxprintf functions
#ifdef WIN
#define _VA_LIST 1
#include <stdarg.h>
#else
#ifndef _VA_LIST
typedef __builtin_va_list va_list;
#define _VA_LIST 1
Expand All @@ -46,7 +50,7 @@ typedef __builtin_va_list va_list;
#define va_end(al) __builtin_va_end(al)

/**
* Expand to an expression that has the type and value of the
* Expand to an expression that has the type and value of the
* next argement in the function call.
*
* @param al Arguments list
Expand All @@ -65,6 +69,7 @@ typedef __builtin_va_list va_list;
* @param s Source variable arguments list
*/
#define va_copy(d, s) __builtin_va_copy(d, s)
#endif

/**
* A simple, non-standard vsnprintf.
Expand All @@ -76,11 +81,11 @@ typedef __builtin_va_list va_list;
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand All @@ -91,7 +96,7 @@ typedef __builtin_va_list va_list;
* For each format specifier, it will take a value from args
* and insert it at that location as that type.
*
* Note: vsnprintf does not call va_end, because it takes a va_list,
* Note: vsnprintf does not call va_end, because it takes a va_list,
* caller does so.
*
* @param buf Output buffer
Expand All @@ -114,11 +119,11 @@ int vsnprintf(char * buf, cgc_size_t buf_size, const char fsm, const char term,
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand Down Expand Up @@ -149,11 +154,11 @@ int snprintf(char * buf, cgc_size_t buf_size, const char fsm, const char term, c
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand All @@ -164,7 +169,7 @@ int snprintf(char * buf, cgc_size_t buf_size, const char fsm, const char term, c
* For each format specifier, it will take a value from args
* and insert it at that location as that type.
*
* Note: vfdprintf does not call va_end, because it takes a va_list,
* Note: vfdprintf does not call va_end, because it takes a va_list,
* caller does so.
*
* @param fd file descriptor to cgc_write to
Expand All @@ -186,11 +191,11 @@ int vfdprintf(int fd, const char fsm, const char term, const char *fmt, va_list
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand Down Expand Up @@ -220,11 +225,11 @@ int fdprintf(int fd, const char fsm, const char term, const char *fmt, ...);
* 'L' for char (one single char)
* 'H' for hex
*
* Note:
* If L is replaced by the term char, then there will be a
* Note:
* If L is replaced by the term char, then there will be a
* term char in the middle of the string. So uses of the resulting
* string will cause issues if cgc_strlen, etc are used.
* If I (itoan) contains term char, then the string will get
* If I (itoan) contains term char, then the string will get
* the decimal representation of the term char in it.
*
* Format string marker is dynamic
Expand Down
Loading

0 comments on commit 3073f36

Please sign in to comment.