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

Make errors — MacOS Catalina, v10.15.7 #20

Open
EDePasquale opened this issue Feb 11, 2021 · 5 comments
Open

Make errors — MacOS Catalina, v10.15.7 #20

EDePasquale opened this issue Feb 11, 2021 · 5 comments

Comments

@EDePasquale
Copy link

A sequence of errors occurred during installation when calling the 'make' command. In general, most of them seem to be related to implicit declarations, examples:

  • newmgrep.c:980:61: error: implicit declaration of function 'eval_tree' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  • recursiv.c:118:3: error: implicitly declaring library function 'strcpy' with type 'char *(char *, const char *)'
    [-Werror,-Wimplicit-function-declaration]
  • bitap.c:106:11: error: implicit declaration of function 're' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    return re(fd, M, D); /* SUN: need to find a even point */

To correct this for my machine, I modified the files to either remove or move the if blocks beginning with 'ifdef_WIN32', though there is likely a better solution that doesn't affect other non-Windows operating systems. To make it successfully build on my machine I changed the following:

  • asearch.c - Comment out 'ifdef_WIN32' on line 26 and 'endif' on line 30
  • asearch1.c - Comment out 'ifdef_WIN32' on line 23 and 'endif' on line 26
  • agrep.c - Moved 'endif' up to like 225, effectively removing the declarations outside of the if block
  • bitap.c - Moved 'endif' up to like 68, effectively removing the declarations outside of the if block
  • main.c - Comment out 'ifdef_WIN32' on line 23 and 'endif' on line 25
  • parse.c - Comment out 'ifdef_WIN32' on line 7 and 'endif' on line 10
  • preproce.c - Comment out 'ifdef_WIN32' on line 45 and 'endif' on line 51
  • recursiv.c - Moved 'int exec();' outside of if block and added 'include <stdlib.h>' near top of file
  • sgrep.c - Comment out 'ifdef_WIN32' on line 126 and 'endif' on line 136
  • newmgrep.c - Comment out 'ifdef_WIN32' on line 122 and 'endif' on line 127
  • utilite.c - Moved 'include <string.h>' outside of if block and added 'include <stdlib.h>' near top of file
  • agrephlp.c - Moved 'endif' up to like 13, effectively removing the declarations outside of the if block

I may have missed a change or 2 while writing this issue, but these same actions can be used to correct other similar errors.

@Wikinaut
Copy link
Owner

thanks for reporting. I have not compiled it on/for Mac. Perhaps you can file a regular pull request, please, so that someone else can pull your request and try that. I am very sorry, that I cannot test it at the moment.

@adamshostack
Copy link

It's easier to change the Makefile:

-CFLAGS = $(MYDEFINEFLAGS) $(SUBDIRCFLAGS)
+CFLAGS = $(MYDEFINEFLAGS) $(SUBDIRCFLAGS) -Wno-implicit-function-declaration

However, I'm not sure how to ifdef that so it only happens on the mac, and turning off that warning seems like a bad idea overall.

@petervangalen
Copy link

I am using @EDePasquale's changes to run agrep on macOS Monterey and Red Hat Enterprise Linux Server Version 7.7 (Maipo). I'm happy to create a pull request but don't want to overreach. @Wikinaut which option do you prefer I use here:
Screen Shot 2022-04-21 at 11 43 31

@Wikinaut
Copy link
Owner

Of course, you can issue a pull request, perhaps best in form of a well-named branch.

@ryandesign
Copy link

ryandesign commented Aug 31, 2023

I have not compiled it on/for Mac.

I am very sorry, that I cannot test it at the moment.

You don't need a Mac to verify the problem or its fix. You can add -Werror=implicit-function-declaration to CFLAGS to test it on any OS with any version of clang (and maybe gcc; I don't know). If you use LLVM.org clang 16 or later, that is even the default behavior (as it is for Apple clang 12 or later).

It's easier to change the Makefile:

-CFLAGS		= $(MYDEFINEFLAGS) $(SUBDIRCFLAGS)
+CFLAGS		= $(MYDEFINEFLAGS) $(SUBDIRCFLAGS) -Wno-implicit-function-declaration

However, I'm not sure how to ifdef that so it only happens on the mac, and turning off that warning seems like a bad idea overall.

Right, don't disable the error. Apple and LLVM.org have made it an error in their respective clangs for a reason. It needs to be fixed properly. Much more information at https://trac.macports.org/wiki/WimplicitFunctionDeclaration.

ryandesign added a commit to ryandesign/agrep that referenced this issue Nov 26, 2023
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

No branches or pull requests

5 participants