Skip to content

Commit

Permalink
AK: Simplify usage of windows.h and winsock2.h
Browse files Browse the repository at this point in the history
Use <AK/Windows.h> instead of windows.h/winsock2.h
to avoid timeval-related errors.

Note: winsock2.h includes windows.h
  • Loading branch information
stasoid committed Dec 9, 2024
1 parent ac590fe commit c2ab1d6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions AK/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ if (BUILD_SHARED_LIBS AND NOT CMAKE_SKIP_INSTALL_RULES AND NOT "${VCPKG_INSTALLE
endif()

if (ENABLE_SWIFT)
set(SWIFT_EXCLUDE_HEADERS Windows.h)
generate_clang_module_map(AK
GENERATED_FILES
"${CMAKE_CURRENT_BINARY_DIR}/Backtrace.h"
Expand Down
4 changes: 1 addition & 3 deletions AK/Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include <AK/Time.h>

#ifdef AK_OS_WINDOWS
# define timeval dummy_timeval
# include <windows.h>
# undef timeval
# include <AK/Windows.h>
#endif

namespace AK {
Expand Down
14 changes: 14 additions & 0 deletions AK/Windows.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2024, stasoid <stasoid@yahoo.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once

#include <AK/Platform.h>

#define timeval dummy_timeval
#include <winsock2.h>
#undef timeval
#include <io.h>

0 comments on commit c2ab1d6

Please sign in to comment.