Tool/software: TI C/C++ Compiler
Hi, there. As title, How to compile one single source file?
I only found a option "Build Selected File(s)", but didn't response anything after clicking it.
I want to compile file sockets.c, but nothing happened after clicking it.
Why I want to compile sockets.c? Because I found a weird thing.
At second image, I can't locate right bracket of function lwip_sendto by right clicking left bracket of it.
I started to debug this function and found that there is a superfluous left bracket at line 40.(Could line number show up before posting?)
int lwip_sendto(int s, const void *data, size_t size, int flags, const struct sockaddr *to, socklen_t tolen) { struct lwip_sock *sock; err_t err; u16_t short_size; const struct sockaddr_in *to_in; u16_t remote_port; #if !LWIP_TCPIP_CORE_LOCKING struct netbuf buf; #endif sock = get_socket(s); if (!sock) { return -1; } if (sock->conn->type == NETCONN_TCP) { #if LWIP_TCP return lwip_send(s, data, size, flags); #else /* LWIP_TCP */ LWIP_UNUSED_ARG(flags); sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1; #endif /* LWIP_TCP */ } /* @todo: split into multiple sendto's? */ LWIP_ASSERT("lwip_sendto: size must fit in u16_t", size <= 0xffff); short_size = (u16_t)size; LWIP_ERROR("lwip_sendto: invalid address", (((to == NULL) && (tolen == 0)) || ((tolen == sizeof(struct sockaddr_in)) && ((to->sa_family) == AF_INET) && ((((mem_ptr_t)to) % 4) == 0))), sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;); to_in = (const struct sockaddr_in *)(void*)to; #if LWIP_TCPIP_CORE_LOCKING /* Should only be consider like a sample or a simple way to experiment this option (no check of "to" field...) */ { struct pbuf* p; ip_addr_t *remote_addr; #if LWIP_NETIF_TX_SINGLE_PBUF p = pbuf_alloc(PBUF_TRANSPORT, short_size, PBUF_RAM); if (p != NULL) { #if LWIP_CHECKSUM_ON_COPY u16_t chksum = 0; if (sock->conn->type != NETCONN_RAW) { chksum = LWIP_CHKSUM_COPY(p->payload, data, short_size); } else #endif /* LWIP_CHECKSUM_ON_COPY */ MEMCPY(p->payload, data, size); #else /* LWIP_NETIF_TX_SINGLE_PBUF */ p = pbuf_alloc(PBUF_TRANSPORT, short_size, PBUF_REF); if (p != NULL) { p->payload = (void*)data; #endif /* LWIP_NETIF_TX_SINGLE_PBUF */ if (to_in != NULL) { inet_addr_to_ipaddr_p(remote_addr, &to_in->sin_addr); remote_port = ntohs(to_in->sin_port); } else { remote_addr = &sock->conn->pcb.raw->remote_ip; if (sock->conn->type == NETCONN_RAW) { remote_port = 0; } else { remote_port = sock->conn->pcb.udp->remote_port; } } LOCK_TCPIP_CORE(); if (sock->conn->type == NETCONN_RAW) { err = sock->conn->last_err = raw_sendto(sock->conn->pcb.raw, p, remote_addr); } else { #if LWIP_UDP #if LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF err = sock->conn->last_err = udp_sendto_chksum(sock->conn->pcb.udp, p, remote_addr, remote_port, 1, chksum); #else /* LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF */ err = sock->conn->last_err = udp_sendto(sock->conn->pcb.udp, p, remote_addr, remote_port); #endif /* LWIP_CHECKSUM_ON_COPY && LWIP_NETIF_TX_SINGLE_PBUF */ #else /* LWIP_UDP */ err = ERR_ARG; #endif /* LWIP_UDP */ } UNLOCK_TCPIP_CORE(); pbuf_free(p); } else { err = ERR_MEM; } } #else /* LWIP_TCPIP_CORE_LOCKING */ /* initialize a buffer */ buf.p = buf.ptr = NULL; #if LWIP_CHECKSUM_ON_COPY buf.flags = 0; #endif /* LWIP_CHECKSUM_ON_COPY */ if (to) { inet_addr_to_ipaddr(&buf.addr, &to_in->sin_addr); remote_port = ntohs(to_in->sin_port); netbuf_fromport(&buf) = remote_port; } else { remote_port = 0; ip_addr_set_any(&buf.addr); netbuf_fromport(&buf) = 0; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, short_size=%"U16_F", flags=0x%x to=", s, data, short_size, flags)); ip_addr_debug_print(SOCKETS_DEBUG, &buf.addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F"\n", remote_port)); /* make the buffer point to the data that should be sent */ #if LWIP_NETIF_TX_SINGLE_PBUF /* Allocate a new netbuf and copy the data into it. */ if (netbuf_alloc(&buf, short_size) == NULL) { err = ERR_MEM; } else { #if LWIP_CHECKSUM_ON_COPY if (sock->conn->type != NETCONN_RAW) { u16_t chksum = LWIP_CHKSUM_COPY(buf.p->payload, data, short_size); netbuf_set_chksum(&buf, chksum); err = ERR_OK; } else #endif /* LWIP_CHECKSUM_ON_COPY */ { err = netbuf_take(&buf, data, short_size); } } #else /* LWIP_NETIF_TX_SINGLE_PBUF */ err = netbuf_ref(&buf, data, short_size); #endif /* LWIP_NETIF_TX_SINGLE_PBUF */ if (err == ERR_OK) { /* send the data */ err = netconn_send(sock->conn, &buf); } /* deallocated the buffer */ netbuf_free(&buf); #endif /* LWIP_TCPIP_CORE_LOCKING */ sock_set_errno(sock, err_to_errno(err)); return (err == ERR_OK ? short_size : -1); }
With extra left bracket, I have no idea that why my library(including this sockets.c source file)is compiled successfully.
So I want to standalone this one and compile it.
Thank you.