-
Notifications
You must be signed in to change notification settings - Fork 630
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
Borland C compiler doesn't like randomize
in pngvalid.c
#601
Comments
Yes, random is expected to be defined in <stdlib.h> because I have _DEFAULT_SOURCE and _BSD_SOURCE defined at the top, but the code doesn't use it. random() and srandom() and other things are defined in XOpen, SVID and BSD but I can't see anywhere where pngvalid attempts to use them and I don't see what it has to do with the function "randomize". pngvalid is C99 because of its use of floating point. |
Oh... ok; they're defining "randomize". Yes, compile with --std=c89 (or c90) will fix it and is required in this case. I think that's good practice anyway; we don't support any pre-ANSI compiler and it would seem that Borland as you are running it is pre-ANSI, In fact pngvalid.c requires C99 so it should probably be checking STDC anyway. ISO don't define the feature test macro I'm using but they do define STDC. |
I want to clarify that Borland C is as modern as it can be, and it supports everything that Clang supports -- unsurprisingly so, considering that its recent implementations are based on Clang. The one that I've just installed (Embarcadero C/C++ 7.70) is based on Clang 15, and it supports C90, C99, C11, C++98/03, C++11, C++14, C++17, and even an early draft of C++20. This |
No problem; pngvalid defines feature test macros for POSIX, BSD and SVID to get functionality which is, IRC, in any one of them and pngvalid deals with the consequences. Something that defines _EMBARCADERO_SOURCE will have to deal with randomize. The requirement is that the base compiler when building libpng is STDC which means that without the feature test macros only ISO-C symbols are defined. Now if ISO-C adds a symbol to one of the C90 headers which is not in one of the reserved sets (like the E symbols in errno.h) there would be a problem. However ISO-C has used new headers instead until last year; stdbool.h (until C23) and stdint.h (or inttypes.h). |
Back to this: I suggest renaming I initially had the intention to give more information in here as to "why", but now I think that PR #603 is the better place. Stay tuned! |
Fixed in both 'libpng16' and 'libpng18'. |
Although I used to be a Borland compiler user ever since Turbo Pascal 5.5 on DOS, I haven't given a spin to their IDEs for many years recently. But earlier today I did just that. I installed C++Builder Community Edition ("turbo-powered" by Clang) and I noticed that
pngvalid.c
doesn't compile becauserandom()
is a macro defined in their<stdlib.h>
. I suppose they're keeping it in for backwards compatibility with their old compilers and libraries, and it only gets out of the way on 64-bit builds and/or when__STDC__
is on.This breakage only happens in C mode, because in C++ mode it becomes a nice inline function tucked away in namespace
std
.So, @jbowler, when you have a chance, could you please update pngvalid.c to your taste, renaming this
libpng/contrib/libtests/pngvalid.c
Line 307 in 626761b
to something else that's more out of the way; say (just a suggestion)
and then
If you're against making a change like this, another alternative would be to enforce compilation in Standard C mode, at least for the Borland compilers (if not more).
The text was updated successfully, but these errors were encountered: