westerndigitalcorporation / swerv-ISS

Western Digital’s Open Source RISC-V SweRV Instruction Set Simulator
201 stars 41 forks source link

Memory.cpp:583:54: error: cannot convert 'gzFile_s**' to 'gzFile {aka gzFile_s*}' #18

Closed avidan-efody closed 4 years ago

avidan-efody commented 4 years ago

It appears that whisper needs a specific zlib version to compile. Running under ubuntu 18.04 or 19.10, with the default zlib installation, gives the following compilation failures:

Memory.cpp: In member function 'bool WdRiscv::Memory::saveSnapshot(const string&)':
Memory.cpp:583:54: error: cannot convert 'gzFile_s**' to 'gzFile {aka gzFile_s*}' for argument '1' to 'int gzwrite(gzFile, voidpc, unsigned int)'
       int resp = gzwrite(gzout, buffer, current_chunk);
                                                      ^
Memory.cpp:594:16: error: cannot convert 'gzFile_s**' to 'gzFile {aka gzFile_s*}' for argument '1' to 'int gzclose(gzFile)'
   gzclose(gzout);
                ^
Memory.cpp: In member function 'bool WdRiscv::Memory::loadSnapshot(const string&)':
Memory.cpp:608:29: error: cannot convert 'gzFile_s**' to 'gzFile {aka gzFile_s*}' for argument '1' to 'int gzeof(gzFile)'
   if (not gzin or gzeof(gzin))
                             ^
Memory.cpp:624:52: error: cannot convert 'gzFile_s**' to 'gzFile {aka gzFile_s*}' for argument '1' to 'int gzread(gzFile, voidp, unsigned int)'
       int resp = gzread(gzin, buffer, current_chunk);
                                                    ^
Memory.cpp:627:31: error: cannot convert 'gzFile_s**' to 'gzFile {aka gzFile_s*}' for argument '1' to 'int gzeof(gzFile)'
           success = gzeof(gzin);
                               ^
Memory.cpp:636:54: error: cannot convert 'gzFile_s**' to 'gzFile {aka gzFile_s*}' for argument '1' to 'const char* gzerror(gzFile, int*)'
               << " failed: " << gzerror(gzin, nullptr) << "\n";
                                                      ^
Memory.cpp:639:26: error: cannot convert 'gzFile_s**' to 'gzFile {aka gzFile_s*}' for argument '1' to 'int gzeof(gzFile)'
   else if (not gzeof(gzin))
                          ^
Memory.cpp:642:15: error: cannot convert 'gzFile_s**' to 'gzFile {aka gzFile_s*}' for argument '1' to 'int gzclose(gzFile)'
   gzclose(gzin);

Modifying the code as follows works:



@@ -563,7 +563,7 @@ Memory::saveSnapshot(const std::string & filename)

-  gzFile* gzout = (gzFile*) gzopen(filename.c_str(), "wb");

+  gzFile gzout = (gzFile) gzopen(filename.c_str(), "wb");

@@ -604,7 +604,7 @@ Memory::loadSnapshot(const std::string & filename)

-  gzFile * gzin = (gzFile *)gzopen(filename.c_str(), "rb");

+  gzFile gzin = (gzFile)gzopen(filename.c_str(), "rb");```
jrahmeh commented 4 years ago

Hi Avidan, Thanks for the fix. It is now merged into the code. Joe

avidan-efody commented 4 years ago

Thanks @jrahmeh