Skip to content
Snippets Groups Projects
Commit 6b9ba603 authored by Nicolas Léveillé's avatar Nicolas Léveillé
Browse files

Allow windows users to include hammer.h

We substitute H_GCC_ATTRIBUTE to any occurence of __attribute__ and
disable its function with non gcc, non clang compilers.

We use a H_ macro so as to not pollute users' namespaces.

On windows build without c4201 so as to allow anonymous struct. This
shows hammer is not C99 compliant but rather C11.
parent e7620e3e
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,13 @@ ...@@ -17,6 +17,13 @@
#ifndef HAMMER_HAMMER__H #ifndef HAMMER_HAMMER__H
#define HAMMER_HAMMER__H #define HAMMER_HAMMER__H
#if defined(__clang__) || defined(__GNUC__)
#define H_GCC_ATTRIBUTE(x) __attribute__(x)
#else
#define H_GCC_ATTRIBUTE(x)
#endif
#ifndef HAMMER_INTERNAL__NO_STDARG_H #ifndef HAMMER_INTERNAL__NO_STDARG_H
#include <stdarg.h> #include <stdarg.h>
#endif // HAMMER_INTERNAL__NO_STDARG_H #endif // HAMMER_INTERNAL__NO_STDARG_H
...@@ -434,7 +441,7 @@ HAMMER_FN_DECL_NOARG(HParser*, h_nothing_p); ...@@ -434,7 +441,7 @@ HAMMER_FN_DECL_NOARG(HParser*, h_nothing_p);
* *
* Result token type: TT_SEQUENCE * Result token type: TT_SEQUENCE
*/ */
HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_sequence, HParser* p); HAMMER_FN_DECL_VARARGS_ATTR(H_GCC_ATTRIBUTE((sentinel)), HParser*, h_sequence, HParser* p);
/** /**
* Given an array of parsers, p_array, apply each parser in order. The * Given an array of parsers, p_array, apply each parser in order. The
...@@ -443,7 +450,7 @@ HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_sequence, HPa ...@@ -443,7 +450,7 @@ HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_sequence, HPa
* *
* Result token type: The type of the first successful parser's result. * Result token type: The type of the first successful parser's result.
*/ */
HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_choice, HParser* p); HAMMER_FN_DECL_VARARGS_ATTR(H_GCC_ATTRIBUTE((sentinel)), HParser*, h_choice, HParser* p);
/** /**
* Given a null-terminated list of parsers, match a permutation phrase of these * Given a null-terminated list of parsers, match a permutation phrase of these
...@@ -469,7 +476,7 @@ HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_choice, HPars ...@@ -469,7 +476,7 @@ HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_choice, HPars
* *
* Result token type: TT_SEQUENCE * Result token type: TT_SEQUENCE
*/ */
HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_permutation, HParser* p); HAMMER_FN_DECL_VARARGS_ATTR(H_GCC_ATTRIBUTE((sentinel)), HParser*, h_permutation, HParser* p);
/** /**
* Given two parsers, p1 and p2, this parser succeeds in the following * Given two parsers, p1 and p2, this parser succeeds in the following
......
...@@ -19,6 +19,9 @@ set WARNINGS=%WARNINGS% -wd4200 ...@@ -19,6 +19,9 @@ set WARNINGS=%WARNINGS% -wd4200
REM c4204 (non-constant aggregate initializers) ressembles C99 support REM c4204 (non-constant aggregate initializers) ressembles C99 support
set WARNINGS=%WARNINGS% -wd4204 set WARNINGS=%WARNINGS% -wd4204
REM c4201 (anonymous unions) ressembles C11 support
set WARNINGS=%WARNINGS% -wd4201
REM c4820 (warnings about padding) is not useful REM c4820 (warnings about padding) is not useful
set WARNINGS=%WARNINGS% -wd4820 set WARNINGS=%WARNINGS% -wd4820
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment