]>
The Tcpdump Group git mirrors - libpcap/blob - diag-control.h
1 /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
3 * Copyright (c) 1993, 1994, 1995, 1996, 1997
4 * The Regents of the University of California. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by the Computer Systems
17 * Engineering Group at Lawrence Berkeley Laboratory.
18 * 4. Neither the name of the University nor of the Laboratory may be used
19 * to endorse or promote products derived from this software without
20 * specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #ifndef _diag_control_h
36 #define _diag_control_h
38 #include "pcap/compiler-tests.h"
41 * Berkeley YACC generates a global declaration of yylval, or the
42 * appropriately prefixed version of yylval, in grammar.h, *even
43 * though it's been told to generate a pure parser, meaning it
44 * doesn't have any global variables*. Bison doesn't do this.
46 * That causes a warning due to the local declaration in the parser
47 * shadowing the global declaration.
49 * So, if this is Berkeley YACC, and we have _Pragma, and have pragmas
50 * to suppress diagnostics, we use it to turn off -Wshadow warnings.
53 #define PCAP_DO_PRAGMA(x) _Pragma (#x)
54 #if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
56 * This is Clang 2.8 or later; we can use "clang diagnostic
57 * ignored -Wxxx" and "clang diagnostic push/pop".
59 #define DIAG_OFF_BYACC \
60 PCAP_DO_PRAGMA(clang diagnostic push) \
61 PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshadow")
62 #define DIAG_ON_BYACC \
63 PCAP_DO_PRAGMA(clang diagnostic pop)
64 #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,2)
66 * This is GCC 4.2 or later, or a compiler claiming to be that.
67 * We can use "GCC diagnostic ignored -Wxxx".
69 #define DIAG_OFF_BYACC \
70 PCAP_DO_PRAGMA(GCC diagnostic push) \
71 PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wshadow")
72 #define DIAG_ON_BYACC \
73 PCAP_DO_PRAGMA(GCC diagnostic pop)
76 * Neither Clang 2.8 or later nor GCC 4.2 or later or a compiler
77 * claiming to be that; there's nothing we know of that we can do.
79 #define DIAG_OFF_BYACC
84 * Not Berkeley YACC, so no warnings to worry about.
86 #define DIAG_OFF_BYACC
90 #endif /* _diag_control_h */