读取struct - uint32没有命名类型

时间:2014-03-03 10:29:11

标签: c++ g++

#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>而因此我加入了它。

还有其他一些我缺少的东西

1 个答案:

答案 0 :(得分:3)

这些类型应该是_t后缀:uint64_t