-2
#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
閱讀結構 - uint32沒有命名一個類型
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>
,因此我將其包含在內。
是否有我失蹤
嘗試'uint32_t',[所有的整數'cstdint'結束類型'_t']( http://en.cppreference.com/w/cpp/header/cstdint)。 – Collin
@VioletGiraffe固定寬度類型來自C++ 11。但是我錯過了缺失的'_t'(這正是我在疲憊的時候得到的),所以我刪除了我的評論。 – computerfreaker