Skip to content

Commit

Permalink
Include 'Merge pull request #147 from Flamefire/fix/missing_include
Browse files Browse the repository at this point in the history
Add missing include: shellapi.h'
  • Loading branch information
Flamefire committed Mar 6, 2022
1 parent fccb720 commit 03d71d6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
15 changes: 11 additions & 4 deletions include/nowide/windows.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// Copyright (c) 2012 Artyom Beilis (Tonkikh)
// Copyright (c) 2022 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE or copy at
Expand All @@ -10,21 +11,27 @@

#ifdef NOWIDE_USE_WINDOWS_H
#include <windows.h>
// (Usually) included by windows.h
#include <shellapi.h>
#else

//
// These are function prototypes... Allow to avoid including windows.h
//
// When NOWIDE_USE_WINDOWS_H is not defined we declare the function prototypes to avoid including windows.h

extern "C" {

// From windows.h

__declspec(dllimport) wchar_t* __stdcall GetEnvironmentStringsW(void);
__declspec(dllimport) int __stdcall FreeEnvironmentStringsW(wchar_t*);
__declspec(dllimport) wchar_t* __stdcall GetCommandLineW(void);
__declspec(dllimport) wchar_t** __stdcall CommandLineToArgvW(const wchar_t*, int*);
__declspec(dllimport) unsigned long __stdcall GetLastError();
__declspec(dllimport) void* __stdcall LocalFree(void*);
__declspec(dllimport) int __stdcall SetEnvironmentVariableW(const wchar_t*, const wchar_t*);
__declspec(dllimport) unsigned long __stdcall GetEnvironmentVariableW(const wchar_t*, wchar_t*, unsigned long);

// From shellapi.h

__declspec(dllimport) wchar_t** __stdcall CommandLineToArgvW(const wchar_t*, int*);
}

#endif
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ nowide_add_test(test_stdio)
nowide_add_test(test_system_n SRC test_system.cpp DEFINITIONS NOWIDE_TEST_USE_NARROW=1)
if(WIN32)
nowide_add_test(test_system_w SRC test_system.cpp DEFINITIONS NOWIDE_TEST_USE_NARROW=0)
nowide_add_test(test_system_use_windows_h SRC test_system.cpp DEFINITIONS NOWIDE_TEST_USE_NARROW=0 BOOST_USE_WINDOWS_H)
nowide_add_test(test_system_use_windows_h_lean SRC test_system.cpp DEFINITIONS NOWIDE_TEST_USE_NARROW=0 BOOST_USE_WINDOWS_H WIN32_LEAN_AND_MEAN)
else()
foreach(test test_filebuf test_ifstream test_ofstream test_fstream test_fstream_special)
nowide_add_test(${test}_internal SRC ${test}.cpp DEFINITIONS NOWIDE_USE_FILEBUF_REPLACEMENT=1 LIBRARIES nowide_file_test_helpers)
Expand Down
2 changes: 1 addition & 1 deletion test/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace nowide {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
#endif
if(c >= std::numeric_limits<char>::min() && c <= std::numeric_limits<char>::max())
if(c >= (std::numeric_limits<char>::min)() && c <= (std::numeric_limits<char>::max)())
ss << static_cast<char>(c);
else
ss << "\\" << std::setw(sizeof(wchar_t) * 2) << static_cast<int>(c) << std::setw(defWidth);
Expand Down
3 changes: 1 addition & 2 deletions test/test_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <nowide/cstdlib.hpp>

#include <nowide/args.hpp>
#include <nowide/cstdlib.hpp>
#include <nowide/utf/convert.hpp>
#include <nowide/utf/utf.hpp>
#include "test.hpp"
Expand Down

0 comments on commit 03d71d6

Please sign in to comment.