This one is driving me crazy, so I just wanted to know if anyone has any hints as to how I might fix this.
I have compiled zlib as a library, and I have included the lib-file in my project along with the header files for the exported functions. This works, and there are no complaints from the compiler or linker.
However, a very strange thing happened when I was modifying some code I was working on. It was a very simple change, I added a missing space to a literal string somewhere in my code. This caused a completely different part of my code (in a different source file) which used zlib to decompress data, to actually stop working (the zlib inflate()-function returned an error, even though it was given the same source data).
The object file with the code that started failing was unchanged, but there was a positional change in the final image due to the one extra space character in the literal string.
How can this happen? The library was unchanged, the code using it was unchanged, yet it failed.
If I change the optimization level I can "fix" the error, but that is of course just conicidence.
I'm using RealView MDK-ARM Version: 3.23.
I think I may have tried almost all combinations of optimizations and other options, both when compiling the library and the actual project. Sometimes it works, sometimes it doesn't.
Can anyone please shed some light for me? I am probably going bald any day soon... :-)