Added minor fixes to build without errors with gcc 4.9.2 #4417
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, I want to thank you for your work on compatibility with quite old compilers!
At work, I happen to use a rather ancient environment & compiler:
gcc --version
:gcc (Debian 4.9.2-10) 4.9.2
gcc -dumpmachine
:arm-linux-gnueabihf
uname -srmio
:Linux 4.1.15-g14db131-dirty armv7l unknown GNU/Linux
.When trying to compile the latest sources (current latest commit: b8121cc) I encountered several compilation errors, which I tried to solve in this pull request. Next, I describe the errors that occurred (in the order they occurred) and the way to solve them.
I build
harfbuzz
with pre-buildfreetype
andicu
with (deprecated) CMake in the next way:Output
Error 1
This error is easier to solve - due to known compiler bugs ('gcc < 5' - missing type traits implementation, we need to use build-in functions instead) - we just need to use already used defines from here:
harfbuzz/src/hb-meta.hh
Lines 202 to 214 in b8121cc
so
harfbuzz/src/hb-map.hh
Lines 109 to 112 in b8121cc
become
Error 2
This is the first time I have encountered errors of this kind, but a quick search suggested that here we need to add an explicit
this->
in related places:So the next code:
harfbuzz/src/hb-map.hh
Lines 399 to 433 in b8121cc
become a little bit explicit:
Error 3
The strangest mistake that took a lot of time. As can be seen from the strange error message, the compiler does not understand what we want at all. Let's look at the relevant code blocks:
harfbuzz/src/hb-object.hh
Lines 160 to 174 in b8121cc
harfbuzz/src/hb-vector.hh
Lines 460 to 467 in b8121cc
The simplest explanation I came up with for this error is: weak support of 'list initialization' (using curly braces) in old compiler. So to solve it I simply replaced 'curly braces' with 'parentheses':
become
and it fixes it! :D
The subsequent build was successful - without errors, although with a few warnings, in the style:
./harfbuzz/src/hb-ot-map.cc:90:44: warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations] hb_ot_map_builder_t::~hb_ot_map_builder_t () ^
Unfortunately, github does not allow to paste the entire build log here. For those interested, you can watch it here.
I really appreciate the support of legacy systems in our imprefect world. I hope this pull request will be considered with understanding. Thanks for your time!