修正VC下的一些编译警告

This commit is contained in:
大石头 2017-02-26 23:22:43 +08:00
parent 5447220c29
commit 835bcc3f15
7 changed files with 25 additions and 16 deletions

View File

@ -1,4 +1,4 @@
#ifndef _Buffer_H_ #ifndef _Buffer_H_
#define _Buffer_H_ #define _Buffer_H_
#include "Type.h" #include "Type.h"

View File

@ -104,7 +104,7 @@ DateTime& DateTime::Parse(int seconds)
DateTime& DateTime::ParseMs(Int64 ms) DateTime& DateTime::ParseMs(Int64 ms)
{ {
Parse(ms / 1000LL); Parse((int)(ms / 1000LL));
Ms = ms % 1000LL; Ms = ms % 1000LL;
return *this; return *this;
@ -129,7 +129,7 @@ DateTime& DateTime::ParseDays(int days)
days -= ytd; days -= ytd;
// 按最大每月31天估算如果超过当月总天数月份加一 // 按最大每月31天估算如果超过当月总天数月份加一
Month = (short)(days / 31 + 1); Month = (byte)(days / 31 + 1);
int mtd = MONTH_TO_DAYS(Year, Month + 1); int mtd = MONTH_TO_DAYS(Year, Month + 1);
if (days >= mtd) Month++; if (days >= mtd) Month++;
@ -137,7 +137,7 @@ DateTime& DateTime::ParseDays(int days)
mtd = MONTH_TO_DAYS(Year, Month); mtd = MONTH_TO_DAYS(Year, Month);
// 今年总天数减去月份天数,得到该月第几天 // 今年总天数减去月份天数,得到该月第几天
Day = (short)(days - mtd + 1); Day = (byte)(days - mtd + 1);
return *this; return *this;
} }
@ -353,7 +353,7 @@ void DateTime::Show(bool newLine) const
f短全部 M/d/yy HH:mm f短全部 M/d/yy HH:mm
F长全部 yyyy-MM-dd HH:mm:ss F长全部 yyyy-MM-dd HH:mm:ss
*/ */
cstring DateTime::GetString(byte kind, char* str) /*cstring DateTime::GetString(byte kind, char* str)
{ {
auto& st = *this; auto& st = *this;
switch(kind) switch(kind)
@ -382,12 +382,12 @@ cstring DateTime::GetString(byte kind, char* str)
} }
return str; return str;
} }*/
// 当前时间 // 当前时间
DateTime DateTime::Now() DateTime DateTime::Now()
{ {
DateTime dt(time(NULL)); DateTime dt((int)time(NULL));
return dt; return dt;
} }

View File

@ -74,7 +74,7 @@ public:
f短全部 M/d/yy HH:mm f短全部 M/d/yy HH:mm
F长全部 yyyy-MM-dd HH:mm:ss F长全部 yyyy-MM-dd HH:mm:ss
*/ */
cstring GetString(byte kind = 'F', char* str = nullptr); //cstring GetString(byte kind = 'F', char* str = nullptr);
// 当前时间 // 当前时间
static DateTime Now(); static DateTime Now();

View File

@ -8,7 +8,7 @@
/************************************************ Random ************************************************/ /************************************************ Random ************************************************/
Random::Random() Random::Random()
{ {
srand(time(NULL)); srand((uint)time(NULL));
} }
Random::Random(uint seed) Random::Random(uint seed)

View File

@ -661,7 +661,7 @@ float String::ToFloat() const
{ {
if(_Length == 0) return 0; if(_Length == 0) return 0;
if(_Arr[_Length] == '\0') return atof(_Arr); if(_Arr[_Length] == '\0') return (float)atof(_Arr);
// 非零结尾字符串需要特殊处理 // 非零结尾字符串需要特殊处理
String s; String s;

View File

@ -7,7 +7,7 @@
/************************************************ TimeSpan ************************************************/ /************************************************ TimeSpan ************************************************/
TimeSpan::TimeSpan(Int64 ms) TimeSpan::TimeSpan(Int64 ms)
{ {
_Seconds = ms / 1000; _Seconds = (int)(ms / 1000);
_Ms = ms % 1000; _Ms = ms % 1000;
} }

View File

@ -55,10 +55,19 @@ public:
//#define ArrayZero(arr) memset(arr, 0, sizeof(arr)) //#define ArrayZero(arr) memset(arr, 0, sizeof(arr))
// 弱函数 // 弱函数
//#if defined(__CC_ARM) #if defined(__CC_ARM)
// #define WEAK __weak #define WEAK __weak
//#elif defined(__GNUC__) #elif defined(__GNUC__)
#define WEAK __attribute__((weak)) #define WEAK __attribute__((weak))
//#endif //#elif defined(_MSC_VER)
// #define WEAK __declspec(selectany)
#else
#define WEAK
#endif
#if defined(_MSC_VER)
//#define itoa _itoa_s
//#define sprintf sprintf_s
#endif
#endif #endif