Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch to compile on Debian Linux 10 #3

Closed
ecm-pushbx opened this issue Aug 28, 2021 · 2 comments
Closed

Patch to compile on Debian Linux 10 #3

ecm-pushbx opened this issue Aug 28, 2021 · 2 comments

Comments

@ecm-pushbx
Copy link

I tried out building revision 9294688 on a Debian Linux 10 server with clang 7.0.1 and gcc 8.3.0 and had to modify a few bits to make everything compile. I uploaded everything to the server and here's just the patch. I didn't test decompression of the resulting file yet but both compilers produce the same output file and its size seems plausible: the 92 KiB of an 86-DOS application binary compressed to 68 KiB, using the default compression scheme.

diff --git a/src/BitStream.h b/src/BitStream.h
index 014c78c..1d03310 100644
--- a/src/BitStream.h
+++ b/src/BitStream.h
@@ -5,6 +5,8 @@
 #define BIT_STREAM_H
 
 #include <vector>
+#include <algorithm>
+#include <cstdint>
 
 class BitStream
 {
diff --git a/src/Main.cpp b/src/Main.cpp
index 776c84f..7515b0c 100644
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -4,6 +4,7 @@
 #include <memory>
 #include <string>
 #include <stdio.h>
+#include <algorithm>
 #include "Compressor.h"
 
 const char* pInputFileError = "Error: Cannot open input file.\n";
@@ -72,7 +73,7 @@ int main(int argCount, char** args)
     }
 
     FILE* pInputFile;
-    if (fopen_s(&pInputFile, args[1], "rb"))
+    if ( (pInputFile = fopen(args[1], "rb")) == NULL )
     {
         printf(pInputFileError);
         return 0;
@@ -89,7 +90,7 @@ int main(int argCount, char** args)
     rewind(pInputFile);
 
     std::unique_ptr<uint8_t[]> spInputStream = std::make_unique<uint8_t[]>(inputFileSize);
-    size_t bytesRead = fread_s(spInputStream.get(), inputFileSize, 1, inputFileSize, pInputFile);
+    size_t bytesRead = fread(spInputStream.get(), 1, inputFileSize, pInputFile);
     fclose(pInputFile);
 
     if (bytesRead != inputFileSize)
@@ -105,7 +106,7 @@ int main(int argCount, char** args)
     }
 
     FILE* pOutputFile;
-    if (fopen_s(&pOutputFile, args[2], "wb"))
+    if ( (pOutputFile = fopen(args[2], "wb")) == NULL )
     {
         printf(pOutputFileError);
         return 0;
diff --git a/src/UniversalCodes.h b/src/UniversalCodes.h
index e40934f..c69cc41 100644
--- a/src/UniversalCodes.h
+++ b/src/UniversalCodes.h
@@ -5,6 +5,8 @@
 #define UNIVERSAL_CODES_H
 
 #include "BitStream.h"
+#include <cassert>
+#define _ASSERT assert
 
 uint32_t GetElias1Cost(uint32_t value);
 void EncodeElias1(BitStream& stream, uint32_t value);
@mbaze
Copy link
Owner

mbaze commented Aug 28, 2021

Thank you, I will try to incorporate this, these are sensible changes to make.

@ecm-pushbx
Copy link
Author

Like you can see in the commands I used I had to pass the switch -Wno-format-security to clang, otherwise it complained in the Main.cpp source file that you used printf with a string constant instead of a string literal. Doesn't really harm anything, just another thing to note.

@mbaze mbaze closed this as completed Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants