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