Skip to content

Conversation

bluca
Copy link
Contributor

@bluca bluca commented Jun 18, 2023

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 (
| ^~~~~~~~~~~~~~~~~

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 (
       | ^~~~~~~~~~~~~~~~~
@steve-o
Copy link
Owner

steve-o commented Jun 21, 2023

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.

@bluca
Copy link
Contributor Author

bluca commented Jun 21, 2023

Wouldn't that be an ABI break?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants