I've found my self in need to use a good compression format library. The LZMA compression matches the bill. I'm using the MinGW64 compiler and when set to compile just the C core files for LZMA with the options "-s", "-O3", "-Wall", and some others for which cpu target (doing multiple compiles). I'm coding for multi-platform, OSX (with intel target), *nix (intel and AMD target), and Windows (intel and AMD target). Before you ask the reason for optimization, it is because this is meant for a real time render engine (aka game engine). Now I've managed to fix all the problems of working the LZMA SDK's C files into a C++ project. Except this one warning, which at first I ignored until the test run.
1 2 3 4 5 6 7 8
X:\code\LZ\XzDec.c||In function 'XzUnpacker_Code':|
X:\code\LZ\XzDec.c|822|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
X:\code\LZ\XzEnc.c||In function 'Xz_WriteFooter':|
X:\code\LZ\XzEnc.c|120|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
X:\code\LZ\XzEnc.c|131|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
X:\code\LZ\XzIn.c||In function 'Xz_ReadBackward':|
X:\code\LZ\XzIn.c|216|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
||=== Build finished: 0 errors, 4 warnings ===|
After seeing that this does cause problems, and looking up on the internet what this means for the code. I found that to get rid of it I could remove all the compiler flags for optimization. Before looking up on the internet I found the exact source of the warning. Which are these macros in file "CpuArch.h":
The same thing with byte swapping for the Big Endian CPUs, but regardless my compiler never reads it because all my targets are Little Endian CPUs. Here is where it gets set from:
Sense this is from within a C library then I would use something to the later to keep things intact. Might go email someone managing the original and point it out so there will be a fix for other people as well.