From e434d404d0db719440cc911729d225417a49b4f4 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 16 Mar 2021 04:33:00 -0700 Subject: [PATCH] Move even more headers outside extern "C". If a header declares a function, or anything else requiring the extern "C" decoration, have it wrap the declaration itself; don't rely on the header itself being included inside extern "C". --- wiretap/wtap_modules.h | 5 ++--- wsutil/cpu_info.h | 2 -- wsutil/file_util.h | 12 ++++++------ wsutil/plugins.h | 6 +++--- wsutil/processes.h | 21 +++++++++++++++------ wsutil/time_util.h | 4 ++-- wsutil/unicode-utils.h | 10 ++++++---- 7 files changed, 34 insertions(+), 26 deletions(-) diff --git a/wiretap/wtap_modules.h b/wiretap/wtap_modules.h index 38114debcb..d105d3d6ef 100644 --- a/wiretap/wtap_modules.h +++ b/wiretap/wtap_modules.h @@ -11,13 +11,12 @@ #ifndef __WTAP_MODULES_H__ #define __WTAP_MODULES_H__ +#include + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#include - - /* * Entry in the table of built-in wiretap modules to register. */ diff --git a/wsutil/cpu_info.h b/wsutil/cpu_info.h index 3579576ba7..145b1bef00 100644 --- a/wsutil/cpu_info.h +++ b/wsutil/cpu_info.h @@ -17,8 +17,6 @@ extern "C" { #endif /* __cplusplus */ -#include "ws_symbol_export.h" - WS_DLL_PUBLIC void get_cpu_info(GString *str); #ifdef __cplusplus diff --git a/wsutil/file_util.h b/wsutil/file_util.h index e9942f3c5b..a2d263d8a2 100644 --- a/wsutil/file_util.h +++ b/wsutil/file_util.h @@ -17,10 +17,6 @@ #include "ws_symbol_export.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #ifdef _WIN32 #include /* for _read(), _write(), etc. */ #include @@ -36,6 +32,12 @@ extern "C" { #include /* for stat() and struct stat */ +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + /* We set a larger IO Buffer size for the capture files */ #define IO_BUF_SIZE (64 * 1024) @@ -58,8 +60,6 @@ extern "C" { #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) #endif -#include - #ifdef _WIN32 /* diff --git a/wsutil/plugins.h b/wsutil/plugins.h index 9eaa0e41ea..5ab8d0ac0f 100644 --- a/wsutil/plugins.h +++ b/wsutil/plugins.h @@ -13,13 +13,13 @@ #include +#include +#include "ws_symbol_export.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#include -#include "ws_symbol_export.h" - typedef void (*plugin_register_func)(void); typedef void plugins_t; diff --git a/wsutil/processes.h b/wsutil/processes.h index 03c76e829d..6d19f97548 100644 --- a/wsutil/processes.h +++ b/wsutil/processes.h @@ -13,6 +13,20 @@ #include "ws_symbol_export.h" +#ifdef _WIN32 +/* + * On Windows, a process ID is a HANDLE. + * Include to make sure HANDLE is defined. + */ +#include +#else +/* + * On UN*X, a process ID is a pid_t. + * Include to make sure pid_t is defined. + */ +#include +#endif + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -20,20 +34,15 @@ extern "C" { #ifdef _WIN32 /* * On Windows, a process ID is a HANDLE. - * Include to make sure HANDLE is defined. */ -#include - typedef HANDLE ws_process_id; #define WS_INVALID_PID INVALID_HANDLE_VALUE + #else /* * On UN*X, a process ID is a pid_t. - * Include to make sure pid_t is defined. */ -#include - typedef pid_t ws_process_id; #define WS_INVALID_PID -1 diff --git a/wsutil/time_util.h b/wsutil/time_util.h index 99d97d662e..40914d29a5 100644 --- a/wsutil/time_util.h +++ b/wsutil/time_util.h @@ -12,12 +12,12 @@ #include "ws_symbol_export.h" +#include + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#include - /** Converts a broken down date representation, relative to UTC, * to a timestamp */ diff --git a/wsutil/unicode-utils.h b/wsutil/unicode-utils.h index 6938914f3f..9a27703cbd 100644 --- a/wsutil/unicode-utils.h +++ b/wsutil/unicode-utils.h @@ -15,6 +15,12 @@ #include +#ifdef _WIN32 +#include +#include +#include +#endif + /** * @file * Unicode convenience routines. @@ -29,10 +35,6 @@ int ws_utf8_char_len(guint8 ch); #ifdef _WIN32 -#include -#include -#include - /** Given a UTF-8 string, convert it to UTF-16. This is meant to be used * to convert between GTK+ 2.x (UTF-8) to Windows (UTF-16). *