bogdasar1985 / bitziplib

A library for working with Huffman Code
GNU Lesser General Public License v2.1
6 stars 0 forks source link

Fix warning which happen with `-O2` flag #19

Open bogdasar1985 opened 3 years ago

bogdasar1985 commented 3 years ago

Fix warnings when compiling with optimization flag level 2 or higher

bogdasar1985 commented 3 years ago
/home/bogdasar/Documents/Programming/C++_Programming/HuffmanCodeLib/extlibs/bitset.cpp:2:2: warning: #warning Do not use bitset, bug there! [-Wcpp]
[ 16%] Linking CXX static library libbitset.a
[ 16%] Built target bitset
[ 25%] Building CXX object extlibs/CMakeFiles/dynamic_array.dir/dynamic_array.cpp.o
[ 33%] Linking CXX static library libdynamic_array.a
[ 33%] Built target dynamic_array
[ 41%] Building CXX object src/huffman/CMakeFiles/hf_priority_queue.dir/hf_priority_queue.cpp.o
/home/bogdasar/Documents/Programming/C++_Programming/HuffmanCodeLib/src/huffman/hf_priority_queue.cpp: In member function ‘void hf_priority_queue::deserialize(FILE*, size_t)’:
/home/bogdasar/Documents/Programming/C++_Programming/HuffmanCodeLib/src/huffman/hf_priority_queue.cpp:103:14: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
  103 |         fread(&ch_tmp, sizeof(ch_tmp), 1, fl);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/bogdasar/Documents/Programming/C++_Programming/HuffmanCodeLib/src/huffman/hf_priority_queue.cpp:104:14: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
  104 |         fread(&sz, sizeof(sz), 1, fl);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
[ 50%] Linking CXX static library libhf_priority_queue.a
[ 50%] Built target hf_priority_queue
[ 58%] Building CXX object src/huffman/CMakeFiles/huffman.dir/huffman.cpp.o
[ 66%] Linking CXX static library ../../lib/libhuffman.a
[ 66%] Built target huffman
[ 75%] Building CXX object examples/file_compressor/CMakeFiles/decoder.dir/decoder.cpp.o
/home/bogdasar/Documents/Programming/C++_Programming/HuffmanCodeLib/examples/file_compressor/decoder.cpp: In function ‘int main(int, char**)’:
/home/bogdasar/Documents/Programming/C++_Programming/HuffmanCodeLib/examples/file_compressor/decoder.cpp:37:10: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   37 |     fread(&less_bits, sizeof(char), 1, source_fl);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/bogdasar/Documents/Programming/C++_Programming/HuffmanCodeLib/examples/file_compressor/decoder.cpp:38:10: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   38 |     fread(&pq_size, sizeof(pq_size), 1, source_fl);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/bogdasar/Documents/Programming/C++_Programming/HuffmanCodeLib/examples/file_compressor/decoder.cpp:50:14: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   50 |         fread(&ch, 1, 1, source_fl);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
[ 83%] Linking CXX executable ../../../examples/file_compressor/decoder
[ 83%] Built target decoder
[ 91%] Building CXX object examples/file_compressor/CMakeFiles/coder.dir/coder.cpp.o
[100%] Linking CXX executable ../../../examples/file_compressor/coder
[100%] Built target coder