Blame gnulib-tests/signature.h

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