Blame gnulib-tests/signature.h

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