Skip to content

Commit

Permalink
Add missing include: shellapi.h
Browse files Browse the repository at this point in the history
CommandLineToArgvW is defined in shellapi.h not windows.h although the former is usually included by the latter unless e.g. WIN32_LEAN_AND_MEAN is defined.
  • Loading branch information
Flamefire committed Mar 6, 2022
1 parent b54d1c2 commit 365013b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 11 additions & 4 deletions include/boost/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 BOOST_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 BOOST_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
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 <boost/nowide/cstdlib.hpp>

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

0 comments on commit 365013b

Please sign in to comment.