1/* Test that fclose works on stderr from glibc 2.0.
2 Copyright (C) 2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <shlib-compat.h>
20
21#if TEST_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
22# define _LIBC
23# define _IO_USE_OLD_IO_FILE
24# include <stdio.h>
25# include <support/check.h>
26
27extern FILE _IO_stderr_;
28compat_symbol_reference (libc, _IO_stderr_, _IO_stderr_, GLIBC_2_0);
29compat_symbol_reference (libc, fclose, fclose, GLIBC_2_0);
30
31__attribute__ ((weak, noclone, noinline))
32void
33do_fclose (FILE *fp)
34{
35 TEST_VERIFY_EXIT (fclose (fp) == 0);
36}
37
38static int
39do_test (void)
40{
41 do_fclose (fp: &_IO_stderr_);
42 return 0;
43}
44#else
45static int
46do_test (void)
47{
48 return 0;
49}
50#endif
51
52#include <support/test-driver.c>
53

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of glibc/libio/tst-stderr-compat.c