读取结构 -- uint32 不命名类型

reading struct -- uint32 does not name a type

本文关键字:类型 uint32 结构 读取      更新时间:2023-10-16
#include <iostream>
#include <map>
#include <zlib.h>
#include <vector>
#include <stdint.h>
using namespace std;
int main (int argc, char **argv)
{
    if(argc <2){        exit(0);}
    //map<int, int> myMap;
    struct last_touch
    {
        vector<uint64> baz;
        uint32 foo;
        uint32 bar;
    }myLastTouch;
    gzFile m_fHandle;
    m_fHandle = gzopen(argv[1], "rb");
    while(!gzeof(m_fHandle))
    {
        gzread(m_fHandle,&myLastTouch, sizeof(last_touch));
        vector<uint64>::size_type sz =  myLastTouch.baz.size();
        cout<<"size t"<<sz<<endl; 
    }   
        gzclose(m_fHandle);
}

我正在尝试从压缩文件中读取结构。我用g++ -lz test.cpp编译它

In function ‘int main(int, char**)’:
test.cpp:15: error: ‘uint64’ was not declared in this scope
test.cpp:15: error: template argument 1 is invalid
test.cpp:15: error: template argument 2 is invalid
test.cpp:16: error: ‘uint32’ does not name a type
test.cpp:17: error: ‘uint32’ does not name a type
test.cpp:27: error: ‘uint64’ cannot appear in a constant-expression
test.cpp:27: error: template argument 1 is invalid
test.cpp:27: error: template argument 2 is invalid
test.cpp:27: error: expected initializer before ‘sz’

这些是我得到的以下错误。我认为 uint32 是因为<stdint.h>,因此我把它包括在内。

我还有什么遗漏的吗

这些类型应该带有_t后缀:uint64_t