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

Adds (void) to all functions taking no args #318

Merged
merged 1 commit into from
May 2, 2023

Conversation

dethrace-labs
Copy link
Owner

This was necessary to make the latest main compile in my OSX environment (clang-14.0.3).

Otherwise, I was seeing error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] for all void functions

@dethrace-labs dethrace-labs requested a review from madebr May 1, 2023 23:36
@madebr
Copy link
Collaborator

madebr commented May 1, 2023

I think this is the wrong approach to fix the error.
We need to be careful to declare public symbols in headers, declare private symbols in the source file, and add static to the private ones. ODR for C.
I did something similar for private symbols in the -Wstrict-prototypes pr.
We should also get rid of all extern function declarations in c sources, such as here. These declarations can get out of sync.

It looks like the warnings you're seeing are warnings emitted by -Wmissing-declarations on gcc

  -Wmissing-declarations
      Warn if a global function is defined without a previous declaration.  Do so even if the definition
      itself provides a prototype.  Use this option to detect global functions that are not declared in header
      files.  In C, no warnings are issued for functions with previous non-prototype declarations; use
      -Wmissing-prototypes to detect missing prototypes.  In C++, no warnings are issued for function
      templates, or for inline functions, or for functions in anonymous namespaces.

example:
the following example will emit the warning you're seeing.
The fix is to add #include <a.h> to a.c.
That way we are sure a.h and a.c remain in sync.

a.h

int my_function(void);

a.c

// no #include <a.h>
int my_function() {
  return arg + 2;
}

@dethrace-labs
Copy link
Owner Author

dethrace-labs commented May 2, 2023

Right, yep, agree with your points 👍

But take a look at BRSRC/DOSIO/eventq.c|h (this was the first file that started complaining).

  • the .c does include the .h

the .h file contains br_error DOSEventBegin(void);, while the .c file has br_error DOSEventBegin() { .. }

Adding the void argument to the .c file fixes the error, presumably because otherwise the signatures do not match?

@madebr
Copy link
Collaborator

madebr commented May 2, 2023

I notice my IDE (=clion) also shows this warning when I hover over DosEventEnd().
Let's apply this one, and in a future pr do an effort to make the code compatible with -Wmissing-declarations.

@dethrace-labs dethrace-labs merged commit 99473ff into main May 2, 2023
@dethrace-labs dethrace-labs deleted the fix_strict_prototypes branch May 2, 2023 11:07
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