openpgm icon indicating copy to clipboard operation
openpgm copied to clipboard

Mark pgm_family_string as 'inline'

Open bluca opened this issue 1 year ago • 2 comments

Functions defined in headers need to be 'static inline', otherwise the compiler will generate an unused-function warning for every program that includes the header but doesn't use the function.

In file included from /usr/include/pgm-5.3/pgm/skbuff.h:39, from /usr/include/pgm-5.3/pgm/msgv.h:33, from /usr/include/pgm-5.3/pgm/pgm.h:44, from src/ip.cpp:53: /usr/include/pgm-5.3/pgm/socket.h:207:1: error: 'const char* pgm_family_string(int)' defined but not used [-Werror=unused-function] 207 | pgm_family_string ( | ^~~~~~~~~~~~~~~~~

bluca avatar Jun 18 '23 13:06 bluca

I think some compilers are overly bad and you end up with linker errors after this, there were problems with both options. Only solution I think is to move the definition out of the header and let the compiler automatically optimize with LTO.

steve-o avatar Jun 21 '23 16:06 steve-o

Wouldn't that be an ABI break?

bluca avatar Jun 21 '23 16:06 bluca