improve compatability with old compiler

This commit is contained in:
Jinhao 2019-06-14 05:34:28 +08:00
parent 80b3566e9b
commit 363953be20
3 changed files with 16 additions and 20 deletions

View File

@ -14,24 +14,23 @@
#if defined(NANA_WINDOWS)
#include <windows.h>
#endif
#include <cassert>
#include <array>
namespace {
std::tm localtime()
{
#if defined(NANA_WINDOWS) && !defined(NANA_MINGW)
time_t t;
::time(&t);
std::time_t t = std::time(nullptr);
std::tm tm;
if (localtime_s(&tm, &t) != 0)
assert(false);
throw std::runtime_error("invalid local time");
return tm;
#else
time_t t = std::time(nullptr);
struct tm * tm_addr = std::localtime(&t);
assert(tm_addr);
if(nullptr == tm_addr)
throw std::runtime_error("invalid local time");
return *tm_addr;
#endif

View File

@ -617,7 +617,7 @@ namespace nana
: std::invalid_argument{ what + " from place implementation " },
pos{ pos },
field { field.empty() ? "unnamed" : field }
field(field.empty() ? "unnamed" : field)
{}
std::string::size_type pos;
std::string field;
@ -3674,18 +3674,18 @@ namespace nana
std::string field,
std::string::size_type pos)
: std::invalid_argument{ "from widget '"
: std::invalid_argument( "from widget '"
+ API::window_caption(plc.window_handle()).substr(0,80)
+ "'; nana::place error "
+ what
+ "' in field '" + field
+ (pos == std::string::npos ? "' " : "' at position " + std::to_string(pos))
+ " in div_text:\n" + plc.div() },
base_what{ what },
owner_caption{ API::window_caption(plc.window_handle()).substr(0,80) },
div_text{ plc.div() },
field{ field },
pos{ pos }
+ " in div_text:\n" + plc.div() ),
base_what( what ),
owner_caption( API::window_caption(plc.window_handle()).substr(0,80) ),
div_text( plc.div() ),
field( field ),
pos( pos )
{}
//end class place

View File

@ -15,7 +15,6 @@
#include <nana/paint/graphics.hpp>
#include <nana/paint/pixel_buffer.hpp>
#include <vector>
#include <cassert>
#include <cstring>
#if defined(NANA_WINDOWS)
@ -71,7 +70,6 @@ namespace nana{ namespace system{
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
HDC hDC = ::GetDC(NULL);
if (::GetDIBits(hDC, (HBITMAP)g.pixmap(), 0, 1, NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS) == 0) {
assert(false);
::ReleaseDC(NULL, hDC);
return false;
}
@ -109,7 +107,6 @@ namespace nana{ namespace system{
::CloseClipboard();
}
}
assert(false);
::GlobalFree(h_gmem);
return false;