quiet / libcorrect

C library for Convolutional codes and Reed-Solomon
BSD 3-Clause "New" or "Revised" License
362 stars 95 forks source link

missing symbols of inline functions #15

Closed piotrszulcaptiv closed 6 years ago

piotrszulcaptiv commented 6 years ago

Hi, Another issue we have found: when compiling without optimization the compiler complains about missing symbols that are defined in metric.h. Shouldn't these be defined in the .c file?

Piotr Szulc

brian-armstrong commented 6 years ago

Which compiler? What's the warning?

brian-armstrong commented 6 years ago

It looks like those functions should be static inline, not just inline.

piotrszulcaptiv commented 6 years ago

The compiler was clang.

I don't have the build log right now, but the linker error was simply as if the functions were defined but not implemented. I solved this by moving the implementation to .c file (but of course they are no longer inline). Seems like this is the same issue: https://stackoverflow.com/questions/16740515/simple-c-inline-linker-error http://clang.llvm.org/compatibility.html#inline

brian-armstrong commented 6 years ago

Thanks for the report. I was able to reproduce and believe I have now fixed it. I'm actually surprised it worked in higher optimization levels.

For performance reasons, it's fairly important those metrics be defined inline. I could just put them in the decoder file, but this allows the code to be shared, and the separation feels a little cleaner.