Blame gnulib-tests/signature.h

Packit Service fdd496
/* Macro for checking that a function declaration is compliant.
Packit Service fdd496
   Copyright (C) 2009-2017 Free Software Foundation, Inc.
Packit Service fdd496
Packit Service fdd496
   This program is free software: you can redistribute it and/or modify
Packit Service fdd496
   it under the terms of the GNU General Public License as published by
Packit Service fdd496
   the Free Software Foundation; either version 3 of the License, or
Packit Service fdd496
   (at your option) any later version.
Packit Service fdd496
Packit Service fdd496
   This program is distributed in the hope that it will be useful,
Packit Service fdd496
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service fdd496
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service fdd496
   GNU General Public License for more details.
Packit Service fdd496
Packit Service fdd496
   You should have received a copy of the GNU General Public License
Packit Service fdd496
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit Service fdd496
Packit Service fdd496
#ifndef SIGNATURE_CHECK
Packit Service fdd496
Packit Service fdd496
/* Check that the function FN takes the specified arguments ARGS with
Packit Service fdd496
   a return type of RET.  This header is designed to be included after
Packit Service fdd496
   <config.h> and the one system header that is supposed to contain
Packit Service fdd496
   the function being checked, but prior to any other system headers
Packit Service fdd496
   that are necessary for the unit test.  Therefore, this file does
Packit Service fdd496
   not include any system headers, nor reference anything outside of
Packit Service fdd496
   the macro arguments.  For an example, if foo.h should provide:
Packit Service fdd496
Packit Service fdd496
   extern int foo (char, float);
Packit Service fdd496
Packit Service fdd496
   then the unit test named test-foo.c would start out with:
Packit Service fdd496
Packit Service fdd496
   #include <config.h>
Packit Service fdd496
   #include <foo.h>
Packit Service fdd496
   #include "signature.h"
Packit Service fdd496
   SIGNATURE_CHECK (foo, int, (char, float));
Packit Service fdd496
   #include <other.h>
Packit Service fdd496
   ...
Packit Service fdd496
*/
Packit Service fdd496
# define SIGNATURE_CHECK(fn, ret, args) \
Packit Service fdd496
  SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
Packit Service fdd496
Packit Service fdd496
/* Necessary to allow multiple SIGNATURE_CHECK lines in a unit test.
Packit Service fdd496
   Note that the checks must not occupy the same line.  */
Packit Service fdd496
# define SIGNATURE_CHECK1(fn, ret, args, id) \
Packit Service fdd496
  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
Packit Service fdd496
# define SIGNATURE_CHECK2(fn, ret, args, id) \
Packit Service fdd496
  static ret (* _GL_UNUSED signature_check ## id) args = fn
Packit Service fdd496
Packit Service fdd496
#endif /* SIGNATURE_CHECK */