-
Notifications
You must be signed in to change notification settings - Fork 160
Description
Both GCC and Clang don't like it when you redeclare functions from the standard library with the wrong types. The main way LLVM-CBE does this is by getting the signedness wrong, because of course LLVM doesn't have signedness in types. (I don't know if there's other ways the types are wrong, but it seems likely.) For both compilers, the warning prompted by these redeclarations can be silenced, but ideally we'd avoid the warning in the first place.
There's a similar thing going on with main, which is a bit more annoying because that's an error by default, rather than a warning. We do of course silence that error also, but it would be nice not to have to.
I am willing to invest a bit of time to try to fix this, at least for common cases.
For main, I think the best thing to do is just to special-case it. It is after all a special case! We can use the correct signature for it, and maybe add casts in the body.
For standard library functions, some possibilities are:
- Don't re-declare standard library functions. But in order to do this, we'd need an accurate list of standard library functions. That sounds troublesome.
- Don't include standard library headers at all. But would that be safe or correct? Does the C standard let us do this? If it does work, it relies on ABI luck…
I suppose a vaguely similar problem can exist for linking against normal C code as well. But arguably we don't need to care so much about that, because you can just write your own wrapper that provides LLVM-CBE-friendly types.