diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-06-30 13:39:01 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-07-03 08:51:48 +0000 |
commit | 0c7f49dd4316b332f30b4ea72a657bace41e1245 (patch) | |
tree | ce4e7b43e8dd32e9daf268cedca2414191f3e472 /src/win32 | |
parent | 2480d0eba85781c802027073a91f6f4331d4f71b (diff) | |
download | libgit2-0c7f49dd4316b332f30b4ea72a657bace41e1245.tar.gz |
Make sure to always include "common.h" first
Next to including several files, our "common.h" header also declares
various macros which are then used throughout the project. As such, we
have to make sure to always include this file first in all
implementation files. Otherwise, we might encounter problems or even
silent behavioural differences due to macros or defines not being
defined as they should be. So in fact, our header and implementation
files should make sure to always include "common.h" first.
This commit does so by establishing a common include pattern. Header
files inside of "src" will now always include "common.h" as its first
other file, separated by a newline from all the other includes to make
it stand out as special. There are two cases for the implementation
files. If they do have a matching header file, they will always include
this one first, leading to "common.h" being transitively included as
first file. If they do not have a matching header file, they instead
include "common.h" as first file themselves.
This fixes the outlined problems and will become our standard practice
for header and source files inside of the "src/" from now on.
Diffstat (limited to 'src/win32')
-rw-r--r-- | src/win32/dir.c | 3 | ||||
-rw-r--r-- | src/win32/dir.h | 1 | ||||
-rw-r--r-- | src/win32/error.c | 2 | ||||
-rw-r--r-- | src/win32/error.h | 2 | ||||
-rw-r--r-- | src/win32/findfile.c | 3 | ||||
-rw-r--r-- | src/win32/findfile.h | 2 | ||||
-rw-r--r-- | src/win32/map.c | 2 | ||||
-rw-r--r-- | src/win32/path_w32.c | 4 | ||||
-rw-r--r-- | src/win32/path_w32.h | 1 | ||||
-rw-r--r-- | src/win32/posix_w32.c | 3 | ||||
-rw-r--r-- | src/win32/precompiled.h | 3 | ||||
-rw-r--r-- | src/win32/thread.c | 1 | ||||
-rw-r--r-- | src/win32/thread.h | 2 | ||||
-rw-r--r-- | src/win32/utf-conv.c | 1 | ||||
-rw-r--r-- | src/win32/utf-conv.h | 3 | ||||
-rw-r--r-- | src/win32/w32_buffer.c | 2 | ||||
-rw-r--r-- | src/win32/w32_buffer.h | 2 | ||||
-rw-r--r-- | src/win32/w32_crtdbg_stacktrace.c | 3 | ||||
-rw-r--r-- | src/win32/w32_crtdbg_stacktrace.h | 2 | ||||
-rw-r--r-- | src/win32/w32_stack.c | 3 | ||||
-rw-r--r-- | src/win32/w32_stack.h | 2 | ||||
-rw-r--r-- | src/win32/w32_util.h | 2 |
22 files changed, 38 insertions, 11 deletions
diff --git a/src/win32/dir.c b/src/win32/dir.c index 8a724a4e9..1d37874e4 100644 --- a/src/win32/dir.c +++ b/src/win32/dir.c @@ -4,6 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "dir.h" + #define GIT__WIN32_NO_WRAP_DIR #include "posix.h" diff --git a/src/win32/dir.h b/src/win32/dir.h index bef39d774..704a9a8a9 100644 --- a/src/win32/dir.h +++ b/src/win32/dir.h @@ -8,6 +8,7 @@ #define INCLUDE_dir_h__ #include "common.h" + #include "w32_util.h" struct git__dirent { diff --git a/src/win32/error.c b/src/win32/error.c index 6b450093f..3a52fb5a9 100644 --- a/src/win32/error.c +++ b/src/win32/error.c @@ -5,8 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "error.h" + #include "utf-conv.h" #ifdef GIT_WINHTTP diff --git a/src/win32/error.h b/src/win32/error.h index 12947a2e6..a2ecf6a6a 100644 --- a/src/win32/error.h +++ b/src/win32/error.h @@ -8,6 +8,8 @@ #ifndef INCLUDE_git_win32_error_h__ #define INCLUDE_git_win32_error_h__ +#include "common.h" + extern char *git_win32_get_error_message(DWORD error_code); #endif diff --git a/src/win32/findfile.c b/src/win32/findfile.c index 1c768f7f4..d56aa1fd2 100644 --- a/src/win32/findfile.c +++ b/src/win32/findfile.c @@ -5,10 +5,11 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "findfile.h" + #include "path_w32.h" #include "utf-conv.h" #include "path.h" -#include "findfile.h" #define REG_MSYSGIT_INSTALL_LOCAL L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1" diff --git a/src/win32/findfile.h b/src/win32/findfile.h index 3d5fff439..1eae4691c 100644 --- a/src/win32/findfile.h +++ b/src/win32/findfile.h @@ -8,6 +8,8 @@ #ifndef INCLUDE_git_findfile_h__ #define INCLUDE_git_findfile_h__ +#include "common.h" + extern int git_win32__find_system_dirs(git_buf *out, const wchar_t *subpath); extern int git_win32__find_global_dirs(git_buf *out); extern int git_win32__find_xdg_dirs(git_buf *out); diff --git a/src/win32/map.c b/src/win32/map.c index 5fcc1085b..6a17aeb64 100644 --- a/src/win32/map.c +++ b/src/win32/map.c @@ -5,6 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "common.h" + #include "map.h" #include <errno.h> diff --git a/src/win32/path_w32.c b/src/win32/path_w32.c index 40b95c33b..f8416b848 100644 --- a/src/win32/path_w32.c +++ b/src/win32/path_w32.c @@ -5,9 +5,9 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" -#include "path.h" #include "path_w32.h" + +#include "path.h" #include "utf-conv.h" #include "posix.h" #include "reparse.h" diff --git a/src/win32/path_w32.h b/src/win32/path_w32.h index 3d9f82860..ac1fb4b9e 100644 --- a/src/win32/path_w32.h +++ b/src/win32/path_w32.h @@ -8,6 +8,7 @@ #define INCLUDE_git_path_w32_h__ #include "common.h" + #include "vector.h" /* diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c index e4fe4142c..c63414aac 100644 --- a/src/win32/posix_w32.c +++ b/src/win32/posix_w32.c @@ -4,6 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "common.h" + #include "../posix.h" #include "../fileops.h" #include "path.h" diff --git a/src/win32/precompiled.h b/src/win32/precompiled.h index 10ca0b80c..851a083d5 100644 --- a/src/win32/precompiled.h +++ b/src/win32/precompiled.h @@ -1,3 +1,5 @@ +#include "common.h" + #include <assert.h> #include <errno.h> #include <limits.h> @@ -20,4 +22,3 @@ #endif #include "git2.h" -#include "common.h" diff --git a/src/win32/thread.c b/src/win32/thread.c index 87318c9d3..2d9600515 100644 --- a/src/win32/thread.c +++ b/src/win32/thread.c @@ -6,6 +6,7 @@ */ #include "thread.h" + #include "../global.h" #define CLEAN_THREAD_EXIT 0x6F012842 diff --git a/src/win32/thread.h b/src/win32/thread.h index 7f4a2170f..d217722ec 100644 --- a/src/win32/thread.h +++ b/src/win32/thread.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_win32_thread_h__ #define INCLUDE_win32_thread_h__ -#include "../common.h" +#include "common.h" #if defined (_MSC_VER) # define GIT_RESTRICT __restrict diff --git a/src/win32/utf-conv.c b/src/win32/utf-conv.c index 96fd4606e..4bde3023a 100644 --- a/src/win32/utf-conv.c +++ b/src/win32/utf-conv.c @@ -5,7 +5,6 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "utf-conv.h" GIT_INLINE(void) git__set_errno(void) diff --git a/src/win32/utf-conv.h b/src/win32/utf-conv.h index 33b95f59f..bab7ba9fd 100644 --- a/src/win32/utf-conv.h +++ b/src/win32/utf-conv.h @@ -7,9 +7,10 @@ #ifndef INCLUDE_git_utfconv_h__ #define INCLUDE_git_utfconv_h__ -#include <wchar.h> #include "common.h" +#include <wchar.h> + #ifndef WC_ERR_INVALID_CHARS # define WC_ERR_INVALID_CHARS 0x80 #endif diff --git a/src/win32/w32_buffer.c b/src/win32/w32_buffer.c index 9122baaa6..45c024d31 100644 --- a/src/win32/w32_buffer.c +++ b/src/win32/w32_buffer.c @@ -5,8 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "w32_buffer.h" + #include "../buffer.h" #include "utf-conv.h" diff --git a/src/win32/w32_buffer.h b/src/win32/w32_buffer.h index 62243986f..e15ea6864 100644 --- a/src/win32/w32_buffer.h +++ b/src/win32/w32_buffer.h @@ -7,6 +7,8 @@ #ifndef INCLUDE_git_win32_buffer_h__ #define INCLUDE_git_win32_buffer_h__ +#include "common.h" + #include "../buffer.h" /** diff --git a/src/win32/w32_crtdbg_stacktrace.c b/src/win32/w32_crtdbg_stacktrace.c index 2dbdaf45b..7b3c3fb4c 100644 --- a/src/win32/w32_crtdbg_stacktrace.c +++ b/src/win32/w32_crtdbg_stacktrace.c @@ -5,9 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "w32_crtdbg_stacktrace.h" + #if defined(GIT_MSVC_CRTDBG) #include "w32_stack.h" -#include "w32_crtdbg_stacktrace.h" #define CRTDBG_STACKTRACE__UID_LEN (15) diff --git a/src/win32/w32_crtdbg_stacktrace.h b/src/win32/w32_crtdbg_stacktrace.h index 2e44fd7cb..bb869b347 100644 --- a/src/win32/w32_crtdbg_stacktrace.h +++ b/src/win32/w32_crtdbg_stacktrace.h @@ -7,6 +7,8 @@ #ifndef INCLUDE_w32_crtdbg_stacktrace_h__ #define INCLUDE_w32_crtdbg_stacktrace_h__ +#include "common.h" + #if defined(GIT_MSVC_CRTDBG) #include <stdlib.h> diff --git a/src/win32/w32_stack.c b/src/win32/w32_stack.c index 15af3dcb7..b40f9d2b4 100644 --- a/src/win32/w32_stack.c +++ b/src/win32/w32_stack.c @@ -5,11 +5,12 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "w32_stack.h" + #if defined(GIT_MSVC_CRTDBG) #include "Windows.h" #include "Dbghelp.h" #include "win32/posix.h" -#include "w32_stack.h" #include "hash.h" /** diff --git a/src/win32/w32_stack.h b/src/win32/w32_stack.h index 21170bd2f..a514ace6f 100644 --- a/src/win32/w32_stack.h +++ b/src/win32/w32_stack.h @@ -8,6 +8,8 @@ #ifndef INCLUDE_w32_stack_h__ #define INCLUDE_w32_stack_h__ +#include "common.h" + #if defined(GIT_MSVC_CRTDBG) /** diff --git a/src/win32/w32_util.h b/src/win32/w32_util.h index 77973b502..d81e55a00 100644 --- a/src/win32/w32_util.h +++ b/src/win32/w32_util.h @@ -8,6 +8,8 @@ #ifndef INCLUDE_w32_util_h__ #define INCLUDE_w32_util_h__ +#include "common.h" + #include "utf-conv.h" #include "posix.h" #include "path_w32.h" |