c++ - 整数常量上的错误后缀 Ui64 无效

标签 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 版的虚拟机,它可以正常工作!

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

最佳答案

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

now -=11644473600000000ULL;

此外,我还找到了一些关于这个的信息C++ integer constants

关于c++ - 整数常量上的错误后缀 Ui64 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25888356/

相关文章:

c++ - 一个类有多个实现文件

c++ - 在 C++ 中使用 SSPI 实现安全连接 - 澄清一些术语

c++ - 如何使用 std::ifstream 读取 UTF-8 编码的文本文件?

c++ - 内存管理 : arrays and dynamic allocation with new operator

c++ - 从 C++ 中读取 PHP 的内容

python +win32 : detect window drag

gcc - *** 检测到缓冲区溢出 ***

c++ - 'memcpy' 未在此范围内声明

c - 调用函数时元素消失 - LZW 压缩

windows - 获取屏幕的平均颜色 - Windows 7 C/C++