Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark pgm_family_string as 'inline' #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

2 participants