Merge pull request #4260 from mathisloge/windows_define

replace _WINDOWS with _WIN32
This commit is contained in:
Artem Pavlenko 2021-10-25 10:25:50 +01:00 committed by GitHub
commit 4eb38c1051
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 44 additions and 40 deletions

View file

@ -14,7 +14,10 @@
{ {
"name": "default-build-dir", "name": "default-build-dir",
"hidden": true, "hidden": true,
"binaryDir": "${sourceDir}/build/${presetName}" "binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
}, },
{ {
"name": "debug-build", "name": "debug-build",

View file

@ -25,7 +25,7 @@
// Windows DLL support // Windows DLL support
#ifdef _WINDOWS #ifdef _WIN32
# define MAPNIK_EXP __declspec (dllexport) # define MAPNIK_EXP __declspec (dllexport)
# define MAPNIK_IMP __declspec (dllimport) # define MAPNIK_IMP __declspec (dllimport)
# ifdef MAPNIK_EXPORTS # ifdef MAPNIK_EXPORTS

View file

@ -30,7 +30,7 @@
#include <iomanip> #include <iomanip>
#include <ctime> #include <ctime>
#ifdef _WINDOWS #ifdef _WIN32
#define NOMINMAX #define NOMINMAX
#include <windows.h> #include <windows.h>
#else #else
@ -45,7 +45,7 @@ namespace mapnik {
// Try to return the time now // Try to return the time now
inline double time_now() inline double time_now()
{ {
#ifdef _WINDOWS #ifdef _WIN32
LARGE_INTEGER t, f; LARGE_INTEGER t, f;
QueryPerformanceCounter(&t); QueryPerformanceCounter(&t);
QueryPerformanceFrequency(&f); QueryPerformanceFrequency(&f);

View file

@ -42,7 +42,7 @@ public:
using data_type = std::unique_ptr<char[]>; using data_type = std::unique_ptr<char[]>;
explicit file(std::string const& filename) explicit file(std::string const& filename)
#ifdef _WINDOWS #ifdef _WIN32
: file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), : file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose),
#else #else
: file_(std::fopen(filename.c_str(),"rb"), std::fclose), : file_(std::fopen(filename.c_str(),"rb"), std::fclose),

View file

@ -23,7 +23,7 @@
#ifndef MAPNIK_UTIL_UTF_CONV_WIN_HPP #ifndef MAPNIK_UTIL_UTF_CONV_WIN_HPP
#define MAPNIK_UTIL_UTF_CONV_WIN_HPP #define MAPNIK_UTIL_UTF_CONV_WIN_HPP
#ifdef _WINDOWS #ifdef _WIN32
// mapnik // mapnik
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
// stl // stl
@ -38,6 +38,6 @@ namespace mapnik
MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str); MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str);
} }
#endif // _WINDOWS #endif // _WIN32
#endif // MAPNIK_UTIL_UTF_CONV_WIN_HPP #endif // MAPNIK_UTIL_UTF_CONV_WIN_HPP

View file

@ -136,7 +136,7 @@ csv_datasource::csv_datasource(parameters const& params)
{ {
throw std::runtime_error("could not create file mapping for " + filename_); throw std::runtime_error("could not create file mapping for " + filename_);
} }
#elif defined (_WINDOWS) #elif defined (_WIN32)
std::ifstream in(mapnik::utf8_to_utf16(filename_),std::ios_base::in | std::ios_base::binary); std::ifstream in(mapnik::utf8_to_utf16(filename_),std::ios_base::in | std::ios_base::binary);
if (!in.is_open()) if (!in.is_open())
{ {
@ -368,7 +368,7 @@ boost::optional<mapnik::datasource_geometry_t> csv_datasource::get_geometry_type
{ {
if (inline_string_.empty()) if (inline_string_.empty())
{ {
#if defined (_WINDOWS) #if defined (_WIN32)
std::ifstream in(mapnik::utf8_to_utf16(filename_),std::ios_base::in | std::ios_base::binary); std::ifstream in(mapnik::utf8_to_utf16(filename_),std::ios_base::in | std::ios_base::binary);
#else #else
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary); std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);

View file

@ -36,7 +36,7 @@ csv_featureset::csv_featureset(std::string const& filename, locator_type const&
: :
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
// //
#elif defined( _WINDOWS) #elif defined( _WIN32)
file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose),
#else #else
file_(std::fopen(filename.c_str(),"rb"), std::fclose), file_(std::fopen(filename.c_str(),"rb"), std::fclose),

View file

@ -49,7 +49,7 @@ csv_index_featureset::csv_index_featureset(std::string const& filename,
tr_("utf8") tr_("utf8")
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
// //
#elif defined( _WINDOWS) #elif defined( _WIN32)
,file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose) ,file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose)
#else #else
,file_(std::fopen(filename.c_str(),"rb"), std::fclose) ,file_(std::fopen(filename.c_str(),"rb"), std::fclose)

View file

@ -39,7 +39,7 @@ geojson_index_featureset::geojson_index_featureset(std::string const& filename,
: :
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
// //
#elif defined _WINDOWS #elif defined(_WIN32)
file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose),
#else #else
file_(std::fopen(filename.c_str(),"rb"), std::fclose), file_(std::fopen(filename.c_str(),"rb"), std::fclose),

View file

@ -36,7 +36,7 @@
geojson_memory_index_featureset::geojson_memory_index_featureset(std::string const& filename, geojson_memory_index_featureset::geojson_memory_index_featureset(std::string const& filename,
array_type && index_array) array_type && index_array)
: :
#ifdef _WINDOWS #ifdef _WIN32
file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose),
#else #else
file_(std::fopen(filename.c_str(),"rb"), std::fclose), file_(std::fopen(filename.c_str(),"rb"), std::fclose),

View file

@ -301,7 +301,7 @@ void ogr_datasource::init(mapnik::parameters const& params)
} }
index_name_ = dataset_name_.substr(0, breakpoint) + ".ogrindex"; index_name_ = dataset_name_.substr(0, breakpoint) + ".ogrindex";
#if defined (_WINDOWS) #if defined (_WIN32)
std::ifstream index_file(mapnik::utf8_to_utf16(index_name_), std::ios::in | std::ios::binary); std::ifstream index_file(mapnik::utf8_to_utf16(index_name_), std::ios::in | std::ios::binary);
#else #else
std::ifstream index_file(index_name_.c_str(), std::ios::in | std::ios::binary); std::ifstream index_file(index_name_.c_str(), std::ios::in | std::ios::binary);

View file

@ -61,7 +61,7 @@ static inline std::string numeric2string(const char* buf)
// All digits after the first must be padded to make the field 4 characters long // All digits after the first must be padded to make the field 4 characters long
if (d != 0) if (d != 0)
{ {
#ifdef _WINDOWS #ifdef _WIN32
int dig = digits[d]; int dig = digits[d];
if (dig < 10) if (dig < 10)
{ {

View file

@ -56,7 +56,7 @@ dbf_file::dbf_file(std::string const& file_name)
record_length_(0), record_length_(0),
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
file_(), file_(),
#elif defined(_WINDOWS) #elif defined(_WIN32)
file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary), file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary),
#else #else
file_(file_name.c_str() ,std::ios::in | std::ios::binary), file_(file_name.c_str() ,std::ios::in | std::ios::binary),

View file

@ -163,7 +163,7 @@ public:
shape_file(std::string const& file_name) : shape_file(std::string const& file_name) :
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
file_() file_()
#elif defined (_WINDOWS) #elif defined(_WIN32)
file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary) file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary)
#else #else
file_(file_name.c_str(), std::ios::in | std::ios::binary) file_(file_name.c_str(), std::ios::in | std::ios::binary)

View file

@ -41,7 +41,7 @@ namespace util {
bool exists(std::string const& filepath) bool exists(std::string const& filepath)
{ {
#ifdef _WINDOWS #ifdef _WIN32
return boost::filesystem::exists(mapnik::utf8_to_utf16(filepath)); return boost::filesystem::exists(mapnik::utf8_to_utf16(filepath));
#else #else
return boost::filesystem::exists(filepath); return boost::filesystem::exists(filepath);
@ -50,7 +50,7 @@ namespace util {
bool is_directory(std::string const& filepath) bool is_directory(std::string const& filepath)
{ {
#ifdef _WINDOWS #ifdef _WIN32
return boost::filesystem::is_directory(mapnik::utf8_to_utf16(filepath)); return boost::filesystem::is_directory(mapnik::utf8_to_utf16(filepath));
#else #else
return boost::filesystem::is_directory(filepath); return boost::filesystem::is_directory(filepath);
@ -59,7 +59,7 @@ namespace util {
bool is_regular_file(std::string const& filepath) bool is_regular_file(std::string const& filepath)
{ {
#ifdef _WINDOWS #ifdef _WIN32
return boost::filesystem::is_regular_file(mapnik::utf8_to_utf16(filepath)); return boost::filesystem::is_regular_file(mapnik::utf8_to_utf16(filepath));
#else #else
return boost::filesystem::is_regular_file(filepath); return boost::filesystem::is_regular_file(filepath);
@ -68,7 +68,7 @@ namespace util {
bool remove(std::string const& filepath) bool remove(std::string const& filepath)
{ {
#ifdef _WINDOWS #ifdef _WIN32
return boost::filesystem::remove(mapnik::utf8_to_utf16(filepath)); return boost::filesystem::remove(mapnik::utf8_to_utf16(filepath));
#else #else
return boost::filesystem::remove(filepath); return boost::filesystem::remove(filepath);
@ -78,7 +78,7 @@ namespace util {
bool is_relative(std::string const& filepath) bool is_relative(std::string const& filepath)
{ {
#ifdef _WINDOWS #ifdef _WIN32
boost::filesystem::path child_path(mapnik::utf8_to_utf16(filepath)); boost::filesystem::path child_path(mapnik::utf8_to_utf16(filepath));
#else #else
boost::filesystem::path child_path(filepath); boost::filesystem::path child_path(filepath);
@ -88,7 +88,7 @@ namespace util {
std::string make_relative(std::string const& filepath, std::string const& base) std::string make_relative(std::string const& filepath, std::string const& base)
{ {
#ifdef _WINDOWS #ifdef _WIN32
boost::filesystem::path absolute_path(mapnik::utf8_to_utf16(base)); boost::filesystem::path absolute_path(mapnik::utf8_to_utf16(base));
#else #else
boost::filesystem::path absolute_path(base); boost::filesystem::path absolute_path(base);
@ -123,7 +123,7 @@ namespace util {
{ {
std::vector<std::string> listing; std::vector<std::string> listing;
boost::filesystem::directory_iterator end_itr; boost::filesystem::directory_iterator end_itr;
#ifdef _WINDOWS #ifdef _WIN32
std::wstring wide_dir(mapnik::utf8_to_utf16(dir)); std::wstring wide_dir(mapnik::utf8_to_utf16(dir));
for (boost::filesystem::directory_iterator itr(wide_dir); itr != end_itr; ++itr) for (boost::filesystem::directory_iterator itr(wide_dir); itr != end_itr; ++itr)
{ {

View file

@ -23,7 +23,7 @@
#include <mapnik/plugin.hpp> #include <mapnik/plugin.hpp>
#include <stdexcept> #include <stdexcept>
#ifdef _WINDOWS #ifdef _WIN32
#define NOMINMAX #define NOMINMAX
#include <windows.h> #include <windows.h>
#define handle HMODULE #define handle HMODULE
@ -54,7 +54,7 @@ PluginInfo::PluginInfo(std::string const& filename,
name_(), name_(),
module_(new mapnik_lib_t) module_(new mapnik_lib_t)
{ {
#ifdef _WINDOWS #ifdef _WIN32
if (module_) module_->dl = LoadLibraryA(filename.c_str()); if (module_) module_->dl = LoadLibraryA(filename.c_str());
if (module_ && module_->dl) if (module_ && module_->dl)
{ {

View file

@ -62,7 +62,7 @@ public:
throw config_error(std::string("Could not load map file: File does not exist"), 0, filename); throw config_error(std::string("Could not load map file: File does not exist"), 0, filename);
} }
filename_ = filename; filename_ = filename;
#ifdef _WINDOWS #ifdef _WIN32
std::basic_ifstream<char> stream(mapnik::utf8_to_utf16(filename)); std::basic_ifstream<char> stream(mapnik::utf8_to_utf16(filename));
#else #else
std::basic_ifstream<char> stream(filename.c_str()); std::basic_ifstream<char> stream(filename.c_str());

View file

@ -1604,7 +1604,7 @@ svg_parser::~svg_parser() {}
void svg_parser::parse(std::string const& filename) void svg_parser::parse(std::string const& filename)
{ {
#ifdef _WINDOWS #ifdef _WIN32
std::basic_ifstream<char> stream(mapnik::utf8_to_utf16(filename)); std::basic_ifstream<char> stream(mapnik::utf8_to_utf16(filename));
#else #else
std::basic_ifstream<char> stream(filename.c_str()); std::basic_ifstream<char> stream(filename.c_str());

View file

@ -20,7 +20,7 @@
* *
*****************************************************************************/ *****************************************************************************/
#ifdef _WINDOWS #ifdef _WIN32
// windows specific methods for UTF8 from/to UTF16 // windows specific methods for UTF8 from/to UTF16
#include <mapnik/util/utf_conv_win.hpp> #include <mapnik/util/utf_conv_win.hpp>
#include <string> #include <string>
@ -58,4 +58,4 @@ std::wstring utf8_to_utf16 (std::string const& str)
} // namespace mapnik } // namespace mapnik
#endif // _WINDOWS #endif // _WIN32

View file

@ -200,13 +200,13 @@ inline int create_disk_index(std::string const& filename, bool silent = true)
cmd += std::string("DYLD_LIBRARY_PATH=") + std::getenv("DYLD_LIBRARY_PATH") + " "; cmd += std::string("DYLD_LIBRARY_PATH=") + std::getenv("DYLD_LIBRARY_PATH") + " ";
} }
cmd += "mapnik-index"; cmd += "mapnik-index";
#ifdef _WINDOWS #ifdef _WIN32
cmd += ".exe"; cmd += ".exe";
#endif #endif
cmd += " " + filename; cmd += " " + filename;
if (silent) if (silent)
{ {
#ifndef _WINDOWS #ifndef _WIN32
cmd += " 2>/dev/null"; cmd += " 2>/dev/null";
#else #else
cmd += " 2> nul"; cmd += " 2> nul";

View file

@ -50,7 +50,7 @@ bool run(std::string const& command, bool okay_to_fail = false)
// silence output unless MAPNIK_TEST_DEBUG is defined // silence output unless MAPNIK_TEST_DEBUG is defined
if (std::getenv("MAPNIK_TEST_DEBUG") == nullptr) if (std::getenv("MAPNIK_TEST_DEBUG") == nullptr)
{ {
#ifndef _WINDOWS #ifndef _WIN32
cmd += " 2>/dev/null"; cmd += " 2>/dev/null";
#else #else
cmd += " 2> nul"; cmd += " 2> nul";

View file

@ -75,7 +75,7 @@ int create_shapefile_index(std::string const& filename, bool index_parts, bool s
cmd += std::string("DYLD_LIBRARY_PATH=") + std::getenv("DYLD_LIBRARY_PATH") + " "; cmd += std::string("DYLD_LIBRARY_PATH=") + std::getenv("DYLD_LIBRARY_PATH") + " ";
} }
cmd += "shapeindex"; cmd += "shapeindex";
#ifdef _WINDOWS #ifdef _WIN32
cmd += ".exe"; cmd += ".exe";
#endif #endif
cmd += " "; cmd += " ";
@ -83,7 +83,7 @@ int create_shapefile_index(std::string const& filename, bool index_parts, bool s
cmd += filename; cmd += filename;
if (silent) if (silent)
{ {
#ifndef _WINDOWS #ifndef _WIN32
cmd += " 2>/dev/null"; cmd += " 2>/dev/null";
#else #else
cmd += " 2> nul"; cmd += " 2> nul";

View file

@ -70,7 +70,7 @@ std::pair<bool,typename T::value_type::first_type> process_csv_file(T & boxes, s
return std::make_pair(false, box_type(p.extent_)); return std::make_pair(false, box_type(p.extent_));
} }
#else #else
#if defined(_WINDOWS) #if defined(_WIN32)
std::ifstream csv_file(mapnik::utf8_to_utf16(filename),std::ios_base::in | std::ios_base::binary); std::ifstream csv_file(mapnik::utf8_to_utf16(filename),std::ios_base::in | std::ios_base::binary);
#else #else
std::ifstream csv_file(filename.c_str(),std::ios_base::in | std::ios_base::binary); std::ifstream csv_file(filename.c_str(),std::ios_base::in | std::ios_base::binary);

View file

@ -79,7 +79,7 @@ static std::string numeric2string(const char* buf)
// All digits after the first must be padded to make the field 4 characters long // All digits after the first must be padded to make the field 4 characters long
if (d != 0) if (d != 0)
{ {
#ifdef _WINDOWS #ifdef _WIN32
int dig = digits[d]; int dig = digits[d];
if (dig < 10) if (dig < 10)
{ {

View file

@ -41,7 +41,8 @@ MAPNIK_DISABLE_WARNING_POP
const int DEFAULT_DEPTH = 8; const int DEFAULT_DEPTH = 8;
const double DEFAULT_RATIO = 0.55; const double DEFAULT_RATIO = 0.55;
#ifdef _WINDOWS #ifdef _WIN32
#define NOMINMAX
#include <windows.h> #include <windows.h>
int main () int main ()
#else #else
@ -73,7 +74,7 @@ int main (int argc,char** argv)
po::positional_options_description p; po::positional_options_description p;
p.add("shape_files",-1); p.add("shape_files",-1);
po::variables_map vm; po::variables_map vm;
#ifdef _WINDOWS #ifdef _WIN32
std::vector<std::string> args; std::vector<std::string> args;
const auto wargs = po::split_winmain(GetCommandLineW()); const auto wargs = po::split_winmain(GetCommandLineW());
for( auto it = wargs.begin() + 1; it != wargs.end(); ++it ) for( auto it = wargs.begin() + 1; it != wargs.end(); ++it )
@ -292,7 +293,7 @@ int main (int argc,char** argv)
if (count > 0) if (count > 0)
{ {
std::clog << " number shapes=" << count << std::endl; std::clog << " number shapes=" << count << std::endl;
#ifdef _WINDOWS #ifdef _WIN32
std::ofstream file(mapnik::utf8_to_utf16(shapename+".index").c_str(), std::ios::trunc | std::ios::binary); std::ofstream file(mapnik::utf8_to_utf16(shapename+".index").c_str(), std::ios::trunc | std::ios::binary);
#else #else
std::ofstream file((shapename+".index").c_str(), std::ios::trunc | std::ios::binary); std::ofstream file((shapename+".index").c_str(), std::ios::trunc | std::ios::binary);