CC errors in wchar.h
Chris Mahoney (1684) 2100 posts |
I’m having a play with an open-source library (uriparser) originally made for Linux, and I’m getting a bizarre error when I try to build it. It makes use of wchar.h and that appears to be where the problem is coming from. I’ve created my own simple makefile: COMPONENT = uriparser OBJS = (the relevant files) C_WARNINGS = -fa include CLibrary Yet when I run amu, I get multiple errors from the wchar.h header provided by CLib: Norcroft RISC OS ARM C vsn 5.72 [07 Apr 2016] "wchar.h", line 74: Error: prototype and old-style parameters mixed "wchar.h", line 74: Error: function prototype formal '__valist' needs type or class - 'int' assumed "wchar.h", line 77: Error: prototype and old-style parameters mixed "wchar.h", line 77: Error: function prototype formal '__valist' needs type or class - 'int' assumed "wchar.h", line 79: Error: prototype and old-style parameters mixed "wchar.h", line 79: Error: function prototype formal '__valist' needs type or class - 'int' assumed "wchar.h", line 81: Error: prototype and old-style parameters mixed "wchar.h", line 81: Error: function prototype formal '__valist' needs type or class - 'int' assumed "wchar.h", line 84: Error: prototype and old-style parameters mixed "wchar.h", line 84: Error: function prototype formal '__valist' needs type or class - 'int' assumed "wchar.h", line 87: Error: prototype and old-style parameters mixed "wchar.h", line 87: Error: function prototype formal '__valist' needs type or class - 'int' assumed Does anyone know what could be causing this? I’m happy to zip up and provide the source if required. |
Rick Murray (539) 13405 posts |
Which variable arguments for is it trying to include? I ran into this problem when I included the wrong one in a project and vsnprintf() threw up a bunch of insane compiler errors like the ones you’ve quoted. ;-) |
Chris Mahoney (1684) 2100 posts |
uriparser isn’t using varargs.h or stdarg.h at all. With that said… … I should’ve read the manual. It specifically says that wchar.h is not currently implemented and will cause an error if used. |
Chris Mahoney (1684) 2100 posts |
And for my next trick… This minimal block of code works fine in Xcode on MacOS (without so much as a warning), and presumably also works in whatever Linux uses: #include <netdb.h> int init_connection(struct addrinfo *res) { return 0; } int main(void) { struct addrinfo *res = NULL; init_connection(res); return 0; } Yet CC returns “<argument 1 to ’init_connection’>: implicit cast of pointer to non-equal pointer”. Does anyone know what’s going on here? They’re both struct addrinfo and I can’t see why this is being rejected. If I try to explicitly cast it then I just get further errors. My makefile is, once again, extremely simple: COMPONENT = test OBJS = main CINCLUDES = -ITCPIPLibs: include CApp |
Rick Murray (539) 13405 posts |
As the definition is *something, shouldn’t you be passing the address of the object, like: init_connection(&res); And I have a feeling that if it’s a reference to a reference, you might want an extra star: int init_connection(struct addrinfo **res) But C’s pointers are messy and weird so don’t quote me on it… |
Jeff Doggett (257) 231 posts |
I’ve just tried this on the compiler on hpux. cc: “fred.c”, line 3: warning 618: Declaration of “addrinfo” not visible outside this function prototype scope. This is caused by the fact that the struct addrinfo isn’t declared in netdb.h |
Leo Smiers (245) 55 posts |
It’s been a long time since I programmed in C, but: What is NULL? is it defined? struct addrinfo *res = (struct addrinfo *)0; |
Chris Mahoney (1684) 2100 posts |
You are absolutely right, in fact the original code does have &res and **res respectively, so perhaps I oversimplified things when bringing it all down to “minimum failing code”. It gives the same error with both notations.
It fails with other values too; NULL was just there to get rid of a warning.
Bingo, we have a winner! I wish the C compiler gave more helpful errors sometimes! The spec states that addrinfo is declared in netdb.h so I assumed that it was there, but sure enough it isn’t declared. In fact, it doesn’t exist at all in the headers provided with the DDE. Fun… It looks like I’m going to have to take a step back and figure out what this code is actually doing now, instead of just trying to build it as-is. That’s always the tricky bit! Thanks for the help :) |
Sprow (202) 1113 posts |
The addrinfo struct (used by getaddrinfo() & freeaddrinfo()) came along in RFC 2553 in March 1999, which, because the RISC OS network stack hasn’t been updated since 1997 means you wont find it anywhere in the DDE which merely includes the various TCPIPLibs libraries. So, your 2 options are
The bounty descriptions can be rather jargon laden, so I guess users (rather than programmers) might be unclear what the benefit to them is. This thread’s a good example – I’m not sure what Chris is trying to port, but we’re missing basic stuff like name resolution functions that are hampering new software being written for RISC OS as a result. |
Rick Murray (539) 13405 posts |
A quick read of the bounty – it didn’t mention replacing the Resolver module with something that, you know, works. I guess it might be necessary for IPv6, but…? |
Steve Pampling (1551) 7932 posts |
It’s some years since I looked at why certain features like reverse lookup didn’t work as expected and I never once glanced beyond pure TCP/IP IPv4.1 1 I was researching the use of DNSBL (black lists) for use in AntiSpam when I discovered a programming shortcut that had risen to bite us. Let’s just say in-addr.arpa isn’t entirely appropriate. |
Chris Mahoney (1684) 2100 posts |
Already did that months ago :)
I have the ISP support, but my router doesn’t like it (even though the documentation says it does). But I don’t have a pressing need to replace it at this stage! |
Steve Pampling (1551) 7932 posts |
Your choice when you do might be influenced by how the manufacturers on your shortlist react to this issue and how they answered the fixing question The bonus for RISC OS is that since we don’t have a wireless stack at all RO itself1 isn’t vulnerable. Never thought you’d see a positive in that did you? 1 of course if other items in your network are vulnerable (and your router is a possible target) then you have a problem anyway. |
Rick Murray (539) 13405 posts |
Samsung haven’t pushed an update for my S7 (yet?). I’m not going to waste any effort wondering about patches for anything else. The answer is a simple NO. As in snowballs and hell. As in there’s a much better chance of Brexit being a glorious rebirth of the British Empire than my IPCam ever seeing a firmware update. And, of course, this is why there is so very much wrong with these sorts of technical specifications being developed by the IEEE and charging ££££$$$$ to get copies of the specs. Let’s see: WEP was painfully lame, WPS is a total farce, and WPA2 has a gaping hole in it. This is what happens when you get committees writing specifications… :-/ |
Steve Pampling (1551) 7932 posts |
Android and Linux implementations seem to suffer worst case due to the interaction with another flaw. Have a read of the researchers article (linked from various pages, I think the register is one such) |
Chris Mahoney (1684) 2100 posts |
FYI: Like with my first question, I went back to the PRM and actually read the instructions. All working :) I think I’ve used up my stupid question quota for the month now! |