What should be done to avoid these warnings?
testsendmsg.c:41: warning: implicit declaration of function `atoi'
testsendmsg.c:49: warning: passing arg 1 of `gethostbyname' from incompatible pointer type
testsendmsg.c:52: warning: implicit declaration of function `exit'
testsendmsg.c:70: warning: passing arg 2 of `strcpy' from incompatible pointer type
testsendmsg.c:72: warning: implicit declaration of function `write'
testsendmsg.c:76: warning: implicit declaration of function `close'
testsendmsg.c:79: warning: return from incompatible pointer type
waiting for a reply.
testsendmsg.c:41: warning: implicit declaration of function `atoi'
testsendmsg.c:52: warning: implicit declaration of function `exit'
testsendmsg.c:72: warning: implicit declaration of function `write'
testsendmsg.c:76: warning: implicit declaration of function `close'
are because you are missing #include files. To find which ones you need, use a Unix shell command such as this
% man atoi
and you'll see what include files you need to add. In this case, you need to add
#include <stdlib.h>
#include <unistd.h>
or at least you did on my machine.
(3) I am not sure what you are trying to do with
STRING_VBS(ipaddress , pipadd)
It doesn't make any sense. It throws up an error on my machine for two reasons
(a) There is no STRING_VBS macro
(b) You are trying to put executable code in between variable declarations, you can do this in C++ but not in C.
(4) You have the statement
portno = atoi(port)
The atoi() function passes a char * as the first argument. See 'man atoi'. You are passing it a 'VAR *' argument. Not only do you get a warning, but this will never work.
There are two ways of solving this
(a) Ask jBASE to return a string which you can pass to atoi() like this
portno = atoi(CONV_CFB(port));
The jBASE macro atoi() will cause the VAR to return the string equivalent of whatever is stored in 'port'.
(b) Ask jBASE to return an integer directly like this
portno = CONV_IB(port)
(5) You had these warning messages
testsendmsg.c:49: warning: passing arg 1 of `gethostbyname' from incompatible pointer type
testsendmsg.c:70: warning: passing arg 2 of `strcpy' from incompatible pointer type
These are the same problems as (4), you are not passing a char * as a parameter, use CONV_CFB ().
I think you need to properly read and understand the jBASE to 'C' interface before progressing further. You seem to have jumped in at the deep end without any real understanding of how you interface jBASE and 'C'. I don't want to be unkind, but it does appear your 'C' experience is somewhat limited, maybe I'm wrong on this, but I do get the impression you are trying to do something which is currently beyond your understanding. Really, you need to read any jBASE documentation on calling C from jBASE.
You really need more experience with C basically I am afraid, but I will try to help. These are standard warnings about your code due to:
1) Although include <jsystem.h> will include most of the useful header files, you may still need others. Hence the implicit declarations. You don’t say what platform you are running, but look up the atoi() and read() etc functions and find out what header file this is included in. Then #include this in your code;
2) Warnings of incompatible types are either because you really are using the wrong pointer, or your calling spec is not an exact match for the function prototype. In the cases below I suggest you are passing a char * or jBASE STRING typedef and need to cast to unsigned char * or the other way around.
Jim
Greg is right, it is your code.
jBASE compiles at a higher warning level than default and so you are not getting the warnings. Specifically, you need to cast the types and include the relevant header files. You should do this anyway and should compile at the highest warning levels available, fixing up the warnings. Occasionally warnings can be too pedantic, but that is what #pragma is for – in general the warnings will only improve your code.
Jim
From:
jB...@googlegroups.com [mailto:jB...@googlegroups.com] On Behalf Of jayasree
Sent: Wednesday, May 16, 2007 3:10 AM
To: jB...@googlegroups.com
Subject: RE: C in jbase
Hi greg,
<BR