From: Guy Harris Date: Tue, 23 Aug 2022 10:32:58 +0000 (-0700) Subject: Use _declspec(deprecated(msg)) rather than __pragma(deprecated). X-Git-Tag: libpcap-1.10.2~68 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/e9aea798a6a700bde827a8cbb3ef01933ccd66fa?ds=sidebyside Use _declspec(deprecated(msg)) rather than __pragma(deprecated). _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) --- diff --git a/pcap/funcattrs.h b/pcap/funcattrs.h index 5dbc428c..3dcf6e61 100644 --- a/pcap/funcattrs.h +++ b/pcap/funcattrs.h @@ -290,10 +290,8 @@ * 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) \ @@ -306,7 +304,7 @@ * 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. @@ -314,7 +312,7 @@ * 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 @@ -323,9 +321,9 @@ * 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 - #define PCAP_DEPRECATED(func, msg) + #define PCAP_DEPRECATED(msg) #endif /* diff --git a/pcap/namedb.h b/pcap/namedb.h index 34a0ae7e..51d1e318 100644 --- a/pcap/namedb.h +++ b/pcap/namedb.h @@ -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 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 *); diff --git a/pcap/pcap.h b/pcap/pcap.h index 3079f6d7..9fd14f5e 100644 --- a/pcap/pcap.h +++ b/pcap/pcap.h @@ -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 -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 *); @@ -614,6 +614,7 @@ PCAP_API int pcap_compile(pcap_t *, struct bpf_program *, const char *, int, 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); @@ -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 -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 *);