implicitly declaring library function 'exit'
A Tool Box with tools written or managed by Jörg Schilling
Brought to you by:
schily
Hi, I'm using Xcode 12.2 beta 2 on macOS, and I downloaded schily-2020-09-22.tar.bz2 and ran make in the top-level directory. It failed, and the reason appears to be that the configure script misdetected the availability of some OS functions due to not including all the required headers for the tests, for example:
configure:19547: checking if mbrtowc is defined or function
configure:19570: gcc -o conftest -g -O2 conftest.c 1>&5
configure:19565:2: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
exit (p != (char *)0 && *p != 0);
^
configure:19565:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
1 error generated.
configure: failed program was:
#line 19552 "configure"
#include "confdefs.h"
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
#ifdef HAVE_WCTYPE_H
#include <wctype.h>
#endif
int main() {
#ifndef mbrtowc
char *p = (char *) mbrtowc;
exit (p != (char *)0 && *p != 0);
#endif
; return 0; }
Starting in Xcode 12, implicit declaration is an error whereas previously it was just a warning. It should be fixed by including the necessary headers.
Having misidentified whether these functions are available at configure time, the build fails later on when your definition of one of the functions collides with the one defined in the system headers, for example:
In file included from fnmatch.c:70:
In file included from ../include/schily/wchar.h:69:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/wchar.h:123:8: error: conflicting types for 'wctomb'
size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
^
../include/schily/wchar.h:64:30: note: expanded from macro 'wcrtomb'
#define wcrtomb(cp, wc, sp) wctomb(cp, wc)
^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:195:6: note: previous declaration is here
int wctomb(char *, wchar_t);
^
Sorry for the delay, your report arrived at a time where I did not immediately reply and I then forgot about it.
I believe a related fix would need in depth testing, since this is a behavior that differs from historic behavior.
In special, checking for other possible occurrences of "error: implicitly" in config.log.
Should I just include the changes in the next regular release or do you like to check the current state?
If you have a fix you'd like me to test before release I can do that.
OK, I copied the new configure file to the schilytools download area.
I'll remove that file this evening in order to avoid confusion for other users.
Do you mean https://sourceforge.net/projects/schilytools/files/? I don't see a separate configure file there.
You could attach a file to this ticket if you want.
Sorry, I copied the file to schillix by mistake. it is now where you expect it.
Please try again.
I downloaded the new configure file and put it into the autoconf directory of schily-2020-11-04 and ran
make. It failed with:Earlier in the configure output I see:
For example the test for size of char failed because:
You could either
#include <stdlib.h>or changeexit()toreturn.Using
grepon the config.log I see 132 implicit function declarations, most of which probably need to be fixed.It seems that Apple is destroying the base of configure...
The assumption is that a missing function prototype only results in a warning.
First,I would need to do some research in order to verify what happens when using return in main() and whether this is usable at all with very old compilers...
Hi,
yesterday I had a discussion with a friend regarding return in main() and older C-compilers.
We now believe that the main thing that was different in the 1980s as that the end of main() had a piece of special code that emulated a return 0, in case there was no return.
So we now believe that it is possible to replace exit by return without destroying portability.
There is a new "configure" script for testing in the schilytools download.
Could you please test that and check foe remaining errors from missing prototypes?
I expect more than 90% of these errors to have gone with the new configure.
Hi, I just uploaded a new version of configure that adds some more #include statements in hope to find nearly all problems.
A new version of schilytools has been published. If there are no remaining problems, I will close this bug in a few days.
Given that there is no new feedback since more than two weeks,
I assume that the recent changes fixed the problem.
Feel free to send a new but report if the problem still exists.