## --------------------------------------------- ##
+# b4_modern_c
+# -----------
+# A predicate useful in #if to determine whether C is ancient or modern.
+#
+# If __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run
+# as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic
+# reasons, but it defines __C99__FUNC__ so check that as well.
+# Microsoft C normally doesn't define these macros, but it defines _MSC_VER.
+# Consider a C++ compiler to be modern if it defines __cplusplus. */
+#
+m4_define([b4_c_modern],
+ [[defined (__STDC__) || defined (__C99__FUNC__) || \
+ defined (__cplusplus) || defined (_MSC_VER)]])
+
# b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
# ----------------------------------------------------------
# Declare the function NAME.
m4_define([b4_c_function_def],
-[#if defined (__STDC__) || defined (__C99__FUNC__) || defined (__cplusplus)
+[#if b4_c_modern
b4_c_ansi_function_def($@)
#else
$2
/* Line __line__ of yacc.c. */
b4_syncline([@oline@], [@ofile@])[
-/* Define YYMODERN_C if this compiler supports C89 or better. If
- __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run
- as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic
- reasons, but it defines __C99__FUNC__ so check that as well.
- Consider a C++ compiler to be modern if it defines __cplusplus. */
-#ifndef YYMODERN_C
-# if defined (__STDC__) || defined (__C99__FUNC__) || defined (__cplusplus)
-# define YYMODERN_C 1
-# else
-# define YYMODERN_C 0
-# endif
-#endif
-
#ifndef YYSIZE_T
# if defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
# elif defined (size_t)
# define YYSIZE_T size_t
-# elif ! defined (YYSIZE_T) && YYMODERN_C
+# elif ! defined (YYSIZE_T) && ]b4_c_modern[
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
-# if ! defined (_ALLOCA_H) && ! defined (_STDLIB_H) && YYMODERN_C
+# if ! defined (_ALLOCA_H) && ! defined (_STDLIB_H) && ]b4_c_modern[
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef _STDLIB_H
# define _STDLIB_H 1
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
-# if ! defined (malloc) && ! defined (_STDLIB_H) && YYMODERN_C
+# if ! defined (malloc) && ! defined (_STDLIB_H) && ]b4_c_modern[
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
-# if ! defined (free) && ! defined (_STDLIB_H) && YYMODERN_C
+# if ! defined (free) && ! defined (_STDLIB_H) && ]b4_c_modern[
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
#endif
-#if YYMODERN_C
+#if ]b4_c_modern[
typedef signed char yysigned_char;
#else
typedef short int yysigned_char;
# define yystrlen strlen
# else
/* Return the length of YYSTR. */
-static YYSIZE_T
-# if YYMODERN_C
-yystrlen (const char *yystr)
-# else
-yystrlen (yystr)
- const char *yystr;
-# endif
+]b4_c_function_def([yystrlen], [static YYSIZE_T],
+ [[const char *yystr], [yystr]])[
{
YYSIZE_T yylen;
for (yylen = 0; yystr[yylen]; yylen++)
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
-static char *
-# if YYMODERN_C
-yystpcpy (char *yydest, const char *yysrc)
-# else
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-# endif
+]b4_c_function_def([yystpcpy], [static char *],
+ [[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[
{
char *yyd = yydest;
const char *yys = yysrc;
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
-# if YYMODERN_C
-int yyparse (void *YYPARSE_PARAM);
-# else
-int yyparse ();
-# endif
+]b4_c_function_decl([yyparse], [int],
+ [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
#else /* ! YYPARSE_PARAM */
]b4_c_function_decl([yyparse], [int], b4_parse_param)[
#endif /* ! YYPARSE_PARAM */
`----------*/
#ifdef YYPARSE_PARAM
-# if YYMODERN_C
-int yyparse (void *YYPARSE_PARAM)
-# else
-int yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-# endif
+b4_c_function_def([yyparse], [int], [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])
#else /* ! YYPARSE_PARAM */
b4_c_function_def([yyparse], [int], b4_parse_param)
#endif