整数常量错误无效后缀Ui64

时间:2014-09-17 10:37:31

标签: c++ windows gcc mingw

我正在尝试构建并运行log4z library。我正在使用Windows 8.1和MinGW与gcc版本4.8.1。

这是 log4z.cpp

代码的一部分
#include "log4z.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <string.h>

#include <string>
#include <vector>
#include <map>
#include <list>
#include <sstream>
#include <iostream>
#include <fstream>
#include <algorithm>


#ifdef WIN32
#include <io.h>
#include <shlwapi.h>
#include <process.h>
#pragma comment(lib, "shlwapi")
#pragma warning(disable:4996)
#else
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include<pthread.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>
#include <semaphore.h>
#endif

...

#ifdef WIN32
        FILETIME ft;
        GetSystemTimeAsFileTime(&ft);
        unsigned long long now = ft.dwHighDateTime;
        now <<= 32;
        now |= ft.dwLowDateTime;
        now /=10;
        now -=11644473600000000Ui64;
        now /=1000;
        pLog->_time = now/1000;
        pLog->_precise = (unsigned int)(now%1000);

...

当我使用CMake和“MinGW Makefiles”生成器构建项目并编译它时,我收到以下错误:

$ mingw32-make
Scanning dependencies of target log4z_win32
[ 25%] Building CXX object g++/CMakeFiles/log4z_win32.dir/__/log4z.cpp.obj
C:\Users\Fenix\Desktop\log4z\log4z.cpp:1219:9: error: invalid suffix "Ui64" on integer constant
   now -=11644473600000000Ui64;
         ^
g++\CMakeFiles\log4z_win32.dir\build.make:53: recipe for target 'g++/CMakeFiles/log4z_win32.dir/__/log4z.cpp.obj' failed
mingw32-make[2]: *** [g++/CMakeFiles/log4z_win32.dir/__/log4z.cpp.obj] Error 1
CMakeFiles\Makefile2:74: recipe for target 'g++/CMakeFiles/log4z_win32.dir/all' failed
mingw32-make[1]: *** [g++/CMakeFiles/log4z_win32.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

但是,我有一个Ubuntu 13.10和gcc版本4.8.1的虚拟机,它可以工作!

我的问题是,我是否需要任何标志来向编译器指示?我需要包含任何库吗?

1 个答案:

答案 0 :(得分:0)

正如@Hans_Passant所说,它可以通过ULL更改Ui64。

now -=11644473600000000ULL;

此外,我找到了有关此C++ integer constants

的一些信息