]> The Tcpdump Group git mirrors - libpcap/commitdiff
Use _declspec(deprecated(msg)) rather than __pragma(deprecated).
authorGuy Harris <[email protected]>
Tue, 23 Aug 2022 10:32:58 +0000 (03:32 -0700)
committerGuy Harris <[email protected]>
Sun, 28 Aug 2022 00:39:36 +0000 (17:39 -0700)
_declspec(deprecated(msg)) doesn't require the function name, and takes
a message as an argument and causes it to be used as the warning/error
message for use of an undeclared function.

(cherry picked from commit c595ef58cf1bc66d475035966850f8b4e14ec175)

pcap/funcattrs.h
pcap/namedb.h
pcap/pcap.h

index 5dbc428c2884160e6ad17ffa2a24cb878549e392..3dcf6e61155cf4094933d05ae68af4744f5eb8e5 100644 (file)
  * PCAP_DEPRECATED(func, msg), after a function declaration, marks the
  * function as deprecated.
  *
  * PCAP_DEPRECATED(func, msg), after a function declaration, marks the
  * function as deprecated.
  *
- * The first argument is the name of the function; the second argument is
- * a string giving the warning message to use if the compiler supports that.
- *
- * (Thank you, Microsoft, for requiring the function name.)
+ * The argument is a string giving the warning message to use if the
+ * compiler supports that.
  */
 #if __has_attribute(deprecated) \
     || PCAP_IS_AT_LEAST_GNUC_VERSION(4,5) \
  */
 #if __has_attribute(deprecated) \
     || PCAP_IS_AT_LEAST_GNUC_VERSION(4,5) \
    * incorrectly, that anything that supports __has_attribute() is
    * recent enough to support __attribute__((deprecated(msg)))).
    */
    * incorrectly, that anything that supports __has_attribute() is
    * recent enough to support __attribute__((deprecated(msg)))).
    */
-  #define PCAP_DEPRECATED(func, msg)   __attribute__((deprecated(msg)))
+  #define PCAP_DEPRECATED(msg) __attribute__((deprecated(msg)))
 #elif PCAP_IS_AT_LEAST_GNUC_VERSION(3,1)
   /*
    * GCC 3.1 through 4.4.
 #elif PCAP_IS_AT_LEAST_GNUC_VERSION(3,1)
   /*
    * GCC 3.1 through 4.4.
    * Those support __attribute__((deprecated)) but not
    * __attribute__((deprecated(msg))).
    */
    * Those support __attribute__((deprecated)) but not
    * __attribute__((deprecated(msg))).
    */
-  #define PCAP_DEPRECATED(func, msg)   __attribute__((deprecated))
+  #define PCAP_DEPRECATED(msg) __attribute__((deprecated))
 #elif defined(_MSC_VER) && !defined(BUILDING_PCAP)
   /*
    * MSVC, and we're not building libpcap itself; it's VS 2015
 #elif defined(_MSC_VER) && !defined(BUILDING_PCAP)
   /*
    * MSVC, and we're not building libpcap itself; it's VS 2015
    * If we *are* building libpcap, we don't want this, as it'll warn
    * us even if we *define* the function.
    */
    * If we *are* building libpcap, we don't want this, as it'll warn
    * us even if we *define* the function.
    */
-  #define PCAP_DEPRECATED(func, msg)   __pragma(deprecated(func))
+  #define PCAP_DEPRECATED(msg) _declspec(deprecated(msg))
 #else
 #else
-  #define PCAP_DEPRECATED(func, msg)
+  #define PCAP_DEPRECATED(msg)
 #endif
 
 /*
 #endif
 
 /*
index 34a0ae7ee373d2b5c5171dab18d28fe7679a0231..51d1e3184b0ee35eb5bd99319f849ca9d3e0c4fe 100644 (file)
@@ -59,8 +59,9 @@ PCAP_API struct       pcap_etherent *pcap_next_etherent(FILE *);
 PCAP_API u_char *pcap_ether_hostton(const char*);
 PCAP_API u_char *pcap_ether_aton(const char *);
 
 PCAP_API u_char *pcap_ether_hostton(const char*);
 PCAP_API u_char *pcap_ether_aton(const char *);
 
-PCAP_API bpf_u_int32 **pcap_nametoaddr(const char *)
-PCAP_DEPRECATED(pcap_nametoaddr, "this is not reentrant; use 'pcap_nametoaddrinfo' instead");
+PCAP_API
+PCAP_DEPRECATED("this is not reentrant; use 'pcap_nametoaddrinfo' instead")
+bpf_u_int32 **pcap_nametoaddr(const char *);
 PCAP_API struct addrinfo *pcap_nametoaddrinfo(const char *);
 PCAP_API bpf_u_int32 pcap_nametonetaddr(const char *);
 
 PCAP_API struct addrinfo *pcap_nametoaddrinfo(const char *);
 PCAP_API bpf_u_int32 pcap_nametonetaddr(const char *);
 
index 3079f6d7fd3ae36b5eb6e0e3ffb7674992a2b431..9fd14f5e9688e3014b0a782b04db7de74833b356 100644 (file)
@@ -391,8 +391,8 @@ PCAP_API int        pcap_init(unsigned int, char *);
  * should use pcap_findalldevs() and use the first device.
  */
 PCAP_AVAILABLE_0_4
  * should use pcap_findalldevs() and use the first device.
  */
 PCAP_AVAILABLE_0_4
-PCAP_API char  *pcap_lookupdev(char *)
-PCAP_DEPRECATED(pcap_lookupdev, "use 'pcap_findalldevs' and use the first device");
+PCAP_DEPRECATED("use 'pcap_findalldevs' and use the first device")
+PCAP_API char  *pcap_lookupdev(char *);
 
 PCAP_AVAILABLE_0_4
 PCAP_API int   pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
 
 PCAP_AVAILABLE_0_4
 PCAP_API int   pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
@@ -614,6 +614,7 @@ PCAP_API int        pcap_compile(pcap_t *, struct bpf_program *, const char *, int,
            bpf_u_int32);
 
 PCAP_AVAILABLE_0_5
            bpf_u_int32);
 
 PCAP_AVAILABLE_0_5
+PCAP_DEPRECATED("use pcap_open_dead(), pcap_compile() and pcap_close()")
 PCAP_API int   pcap_compile_nopcap(int, int, struct bpf_program *,
            const char *, int, bpf_u_int32);
 
 PCAP_API int   pcap_compile_nopcap(int, int, struct bpf_program *,
            const char *, int, bpf_u_int32);
 
@@ -680,8 +681,8 @@ PCAP_API FILE       *pcap_file(pcap_t *);
  * a Windows-only pcap_handle() API that returns the HANDLE.
  */
 PCAP_AVAILABLE_0_4
  * a Windows-only pcap_handle() API that returns the HANDLE.
  */
 PCAP_AVAILABLE_0_4
-PCAP_API int   pcap_fileno(pcap_t *)
-PCAP_DEPRECATED(pcap_fileno, "request a 'pcap_handle' that returns a HANDLE if you need it");
+PCAP_DEPRECATED("request a 'pcap_handle' that returns a HANDLE if you need it")
+PCAP_API int   pcap_fileno(pcap_t *);
 #else /* _WIN32 */
 PCAP_AVAILABLE_0_4
 PCAP_API int   pcap_fileno(pcap_t *);
 #else /* _WIN32 */
 PCAP_AVAILABLE_0_4
 PCAP_API int   pcap_fileno(pcap_t *);