Hi, I am very new with makefile topics , maybe this is a very symple question...
I have this code wich compile very good ( I get it from the net), I will call it code A.
I have to add it with a program that is all ready in use, (code B) that also compile good. When I put together it doesnt compile anymore. The problem is that I have to use the makefile of the code B, wich have in this line:
PACKDEFS = -I$(CMX_AUTO_INCLUDE) -I$(CMX_USER_INCLUDE) -Aa
If I remove the instruction -Aa ( I think is used to ansi C) my code A compiles, but the code B doesnt.
I dont know how to do it since I need both codes works together.
Code A:
/* tcpclient.c */
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
int main()
{
int sock, bytes_recieved;
char send_data[1024],recv_data[1024];
struct hostent *host;
struct sockaddr_in server_addr;
char header[15];
host = gethostbyname("prueba");
if ( host==NULL)
{
printf (" no encuentro la direccion \n");
}
printf ("la direecion es %s \n", host->h_addr_list );
printf("\n eNTRando en acCCioN...\n ");
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("Socket");
exit(1);
}
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(5000);
server_addr.sin_addr = *((struct in_addr *)host->h_addr);
bzero(&(server_addr.sin_zero),8);
if (connect(sock, (struct sockaddr *)&server_addr,
sizeof(struct sockaddr)) == -1)
{
perror("Connect");
exit(1);
}
while(1)
{
printf("\n ES hora de mandar datos.. que desea enviar? (q or Q to quit) : ");
gets(header);
send_data[0]= 0x02;
send_data[1]= 0x07;
send_data[2]= 0x31;
send_data[3]= 0x31;
send_data[4]= 0x17;
strcat (send_data,header);
header[0]= 0x05;
header[1]= '\0';
strcat (send_data,header);
if (strcmp(send_data , "q") == 0 || strcmp(send_data , "Q") == 0)
{
send(sock, send_data,strlen(send_data), 0);
close(sock);
break;
}
else
send(sock, send_data,strlen(send_data), 0);
bytes_recieved=recv(sock,recv_data,1024,0);
recv_data[bytes_recieved] = '\0';
if (strcmp(recv_data , "q") == 0 || strcmp(recv_data , "Q") == 0)
{
close(sock);
break;
}
else
printf("\nRecieved data = %s " , recv_data);
printf("\nSEND (q or Q to quit) : ");
gets(send_data);
if (strcmp(send_data , "q") != 0 && strcmp(send_data , "Q") != 0)
send(sock,send_data,strlen(send_data), 0);
else
{
send(sock,send_data,strlen(send_data), 0);
close(sock);
break;
}
}
return 0;
}
Compiling error:
ulcmx1:oasys:prueba> make new
--- Completed TARGET=clean:/usr/oasys/V5.2.2/source/project/simcot/prueba./HP/
--- Completed TARGET=depend:/usr/oasys/V5.2.2/source/project/simcot/prueba
Lib
--- Completed TARGET=LIB:/usr/oasys/V5.2.2/source/project/simcot/prueba
cc -c -DHP -DSYSTEM_10 +u4 -DSAMMI3 -I/usr/oasys/V5.2.2/source/include/auto/HP -I/usr/oasys/V5.2.2/source/include/user -Aa tcp.c -o ./HP/tcp.o
cc: "tcp.c", line 29: error 1574: Unknown size for "server".
cc: "tcp.c", line 30: error 1594: The sizeof operator cannot be applied to types with unknown size.
cc: "tcp.c", line 50: error 1588: "AF_INET" undefined.
cc: "tcp.c", line 50: error 1588: "SOCK_STREAM" undefined.
cc: "tcp.c", line 68: error 1530: Undefined struct or union.
cc: "tcp.c", line 73: error 1530: Undefined struct or union.
cc: "tcp.c", line 73: error 1529: Cannot select field of non-structure.
cc: "tcp.c", line 73: error 1588: "INADDR_ANY" undefined.
*** Error exit code 1
I wont put code B because it is long.
Thanks