【问题标题】:error invalid suffix Ui64 on integer constant整数常量上的错误后缀 Ui64 无效
【发布时间】:2014-09-17 10:37:30
【问题描述】:

我正在尝试构建和运行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 的虚拟机,它可以工作!

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

【问题讨论】:

标签: c++ windows gcc mingw


【解决方案1】:

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

now -=11644473600000000ULL;

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-12
    • 1970-01-01
    • 1970-01-01
    • 2013-10-21
    • 1970-01-01
    • 2020-01-19
    相关资源
    最近更新 更多