前进的道路不是一帆风顺的,要随时迎接挑战,敢于战胜困难!

坚持一下,找人聊聊天,释放一些压力!

 

Linux g++关于warning: extra tokens at end of #endif directive

原文件TimeSynManager.h

 

#ifndef  TimeSynManager_h__
#define TimeSynManager_h__

const int max_year=1100;
const int min_year=70;
typedef   long long   __int64;

#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
//#include <atltime.h>

typedef /*__time64_t*/time_t UTC_time_t ;
typedef struct tm UTC_tm;
//typedef class CTimeSpan CUtcTimeSpan;

class TimeSynManager;

class CTmParser

public:
 enum E_TYPE
    {
        E_TYPE_A=1, //"yy-mm-dd TT:UU:SS" ex.2009-02-10 14:03:00"
  E_TYPE_B, //"mm dd yy HH:MM:SS" ex.May 7 2009 14:36:15"
  E_TYPE_C, //"string" ex.123456789
  E_TYPE_D, //"week month day hour:minute:second year" ex.Fri May 08 13:29:56 2009
        E_TYPE_DEFAULT = E_TYPE_C
    };

 enum E_OUT_TYPE
    {
        E_OUT_A=1, //"yy-mm-dd TT:UU:SS" ex.2009-02-10 14:03:00"
  E_OUT_B, //"mm dd yy HH:MM:SS" ex.May 7 2009 14:36:15"
  E_OUT_C, //"string" ex.123456789
  E_OUT_D, //"week month day hour:minute:second year" ex.Fri May 08 13:29:56 2009
        E_OUT_DEFAULT = E_OUT_C
    };

 enum MONTH_SHORT
 {
  Jan=1,
  Feb,
  Mar,
  Apr,
  May,
  Jun,
  Jul,
  Aug,
  Sep,
  Oct,
  Nov,
  Dec
 };

public:
 CTmParser( const char *parseTm,E_TYPE tp=E_TYPE_DEFAULT);
 CTmParser( struct tm *newtime,E_OUT_TYPE tp=E_OUT_DEFAULT);
 ~CTmParser(void);
 
private:
 UTC_tm &parse();
    void parseAType();
 void ParseBType();
 void ParseCType();
 void ParseDType();
 void ParseMonthShort(char *month);
 void ExeMoth();
 bool IsNum(char *para);
 bool IsMonthShort(char *month);

 char *Output();
 char *OutPutAType();
 char *OutPutBType();
 char *OutPutCType();
 char *OutPutDType();

private:
 UTC_tm m_tmStru ;
    E_TYPE m_type;
 E_OUT_TYPE m_out_type;
 MONTH_SHORT m_month;
    const char *m_parseSrc;
 struct tm *m_outtime;
    friend class TimeSynManager; 
};

class TimeSynManager

public:   
    //(3000-1970)
    const static int S_MAX_YEAR_LENTH = 1030;
    static UTC_time_t getCurTimeVal()
 {       
  return  /*_time64*/time(NULL); //参数取NULL表示获取当前时间
 }
    TimeSynManager();
    TimeSynManager(UTC_time_t tmVal);
    TimeSynManager(UTC_tm &tm);
    TimeSynManager(const char* pszTime, CTmParser::E_TYPE type);
 TimeSynManager(struct tm *newtime, CTmParser::E_OUT_TYPE type, char *output);
    ~TimeSynManager(void);
    bool operator ==(TimeSynManager & dt);
    bool operator >(TimeSynManager & dt);
    bool operator >=(TimeSynManager & dt);
    bool operator <(TimeSynManager & dt);
    bool operator <=(TimeSynManager & dt);
    __int64 operator -(TimeSynManager & dt);
 const char* dumpTime( char buff[],int MaxLen);
    //TimeSynManager add(CUtcTimeSpan sp );
    TimeSynManager  add( __int64 tmValInterval );
    //TimeSynManager  sub(CUtcTimeSpan sp );
    TimeSynManager  sub( __int64 tmValInterval );

public:
    UTC_tm m_TmStru;
    UTC_time_t  m_tmVal; 
};

#endif TimeSynManager_h__

 

修改后的文件TimeSynManager.h

 

#ifndef  TimeSynManager_h__
#define TimeSynManager_h__

const int max_year=1100;
const int min_year=70;
typedef   long long   __int64;

#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
//#include <atltime.h>

typedef /*__time64_t*/time_t UTC_time_t ;
typedef struct tm UTC_tm;
//typedef class CTimeSpan CUtcTimeSpan;

class TimeSynManager;

class CTmParser

public:
 enum E_TYPE
    {
        E_TYPE_A=1, //"yy-mm-dd TT:UU:SS" ex.2009-02-10 14:03:00"
  E_TYPE_B, //"mm dd yy HH:MM:SS" ex.May 7 2009 14:36:15"
  E_TYPE_C, //"string" ex.123456789
  E_TYPE_D, //"week month day hour:minute:second year" ex.Fri May 08 13:29:56 2009
        E_TYPE_DEFAULT = E_TYPE_C
    };

 enum E_OUT_TYPE
    {
        E_OUT_A=1, //"yy-mm-dd TT:UU:SS" ex.2009-02-10 14:03:00"
  E_OUT_B, //"mm dd yy HH:MM:SS" ex.May 7 2009 14:36:15"
  E_OUT_C, //"string" ex.123456789
  E_OUT_D, //"week month day hour:minute:second year" ex.Fri May 08 13:29:56 2009
        E_OUT_DEFAULT = E_OUT_C
    };

 enum MONTH_SHORT
 {
  Jan=1,
  Feb,
  Mar,
  Apr,
  May,
  Jun,
  Jul,
  Aug,
  Sep,
  Oct,
  Nov,
  Dec
 };

public:
 CTmParser( const char *parseTm,E_TYPE tp=E_TYPE_DEFAULT);
 CTmParser( struct tm *newtime,E_OUT_TYPE tp=E_OUT_DEFAULT);
 ~CTmParser(void);
 
private:
 UTC_tm &parse();
    void parseAType();
 void ParseBType();
 void ParseCType();
 void ParseDType();
 void ParseMonthShort(char *month);
 void ExeMoth();
 bool IsNum(char *para);
 bool IsMonthShort(char *month);

 char *Output();
 char *OutPutAType();
 char *OutPutBType();
 char *OutPutCType();
 char *OutPutDType();

private:
 UTC_tm m_tmStru ;
    E_TYPE m_type;
 E_OUT_TYPE m_out_type;
 MONTH_SHORT m_month;
    const char *m_parseSrc;
 struct tm *m_outtime;
    friend class TimeSynManager; 
};

class TimeSynManager

public:   
    //(3000-1970)
    const static int S_MAX_YEAR_LENTH = 1030;
    static UTC_time_t getCurTimeVal()
 {       
  return  /*_time64*/time(NULL); //参数取NULL表示获取当前时间
 }
    TimeSynManager();
    TimeSynManager(UTC_time_t tmVal);
    TimeSynManager(UTC_tm &tm);
    TimeSynManager(const char* pszTime, CTmParser::E_TYPE type);
 TimeSynManager(struct tm *newtime, CTmParser::E_OUT_TYPE type, char *output);
    ~TimeSynManager(void);
    bool operator ==(TimeSynManager & dt);
    bool operator >(TimeSynManager & dt);
    bool operator >=(TimeSynManager & dt);
    bool operator <(TimeSynManager & dt);
    bool operator <=(TimeSynManager & dt);
    __int64 operator -(TimeSynManager & dt);
 const char* dumpTime( char buff[],int MaxLen);
    //TimeSynManager add(CUtcTimeSpan sp );
    TimeSynManager  add( __int64 tmValInterval );
    //TimeSynManager  sub(CUtcTimeSpan sp );
    TimeSynManager  sub( __int64 tmValInterval );

public:
    UTC_tm m_TmStru;
    UTC_time_t  m_tmVal; 
};

#endif //TimeSynManager_h__

哈哈,其实就改了最后一行,将生命注释起来。

posted on 2009-05-21 10:01  山径山精  阅读(5308)  评论(0编辑  收藏  举报

导航