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

Missing declarations runner #1921

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

albinahlback
Copy link
Collaborator

@albinahlback albinahlback commented Apr 12, 2024

Currently we have functions that are declared as global functions, but miss declarations in headers. Now, some may be missed in headers, other should be converted to static functions. Compiling with -Wmissing-prototypes shows which ones it is.

Doing this can show which ones should actually be local/static and which ones may miss a declaration in a header. On the other hand, if a helper function defined as a global function is no longer used, but still defined, it will still be compiled and take up space in the binary and in the source code. Hence, we should aim to cover the whole library with this compiler flag (will probably take years to fix this, thought).

Some files are problematic, such as inlines.c, but an easy guard with

#if defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
#endif

#include "footer.h"

#if defined(__GNUC__)
# pragma GCC diagnostic pop
#endif

fixes this

I think it is necessary to be able to sanitize the FLINT source code, but I'll wait a day or so before merging this in case someone has any objections.

@edgarcosta
Copy link
Member

edgarcosta commented Apr 12, 2024 via email

@albinahlback albinahlback force-pushed the missing_declarations branch 3 times, most recently from 6cb2109 to 1ac99c2 Compare April 13, 2024 09:55
@fredrik-johansson
Copy link
Collaborator

I would really prefer to just insert more forward declarations instead of littering the codebase with pragmas except in very special circumstances.

@albinahlback
Copy link
Collaborator Author

I would really prefer to just insert more forward declarations instead of littering the codebase with pragmas except in very special circumstances.

How about *-impl.h headers? That would allow us to keep track of global private functions and avoid us from using pragmas.

@fredrik-johansson
Copy link
Collaborator

How about *-impl.h headers? That would allow us to keep track of global private functions and avoid us from using pragmas.

I don't see the need. Nothing prevents us from declaring "global private" functions in the existing headers.

@albinahlback
Copy link
Collaborator Author

How about *-impl.h headers? That would allow us to keep track of global private functions and avoid us from using pragmas.

I don't see the need. Nothing prevents us from declaring "global private" functions in the existing headers.

Ah, sorry. I have no objection to this. Will do this instead.

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.

3 participants