File: compile_fail-function-param.c

package info (click to toggle)
pdbg 3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,212 kB
  • sloc: ansic: 21,934; cpp: 3,363; sh: 3,343; makefile: 314; asm: 11
file content (24 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <ccan/array_size/array_size.h>
#include <stdlib.h>

struct foo {
	unsigned int a, b;
};

int check_parameter(const struct foo array[4]);
int check_parameter(const struct foo array[4])
{
#ifdef FAIL
	return (ARRAY_SIZE(array) == 4);
#if !HAVE_TYPEOF || !HAVE_BUILTIN_TYPES_COMPATIBLE_P
#error "Unfortunately we don't fail if _array_size_chk is a noop."
#endif
#else
	return sizeof(array) == 4 * sizeof(struct foo);
#endif
}

int main(int argc, char *argv[])
{
	return check_parameter(NULL);
}