1

Ubuntu 10.04 32-bit, eclipse, C and C++

I have a program that uses select() to monitor a bunch of TCP and UDP ports. I create those ports in the usual way (socket(), bind(), listen(), accept() etc.) using sockaddr_in structures.

The program works fine at the command line. I was using the eclipse debugger to fix a bug (fixed now!) when I noticed the following warning:

warning: can't find linker symbol for virtual table for `sockaddr_in' value
warning:   found `operator delete(void*)' instead

Well, after fixing my bug I checked and the warning persisted.

I know that the warnings commence as soon as I enter my ConfigureServer() routine where the ports/sockets get connected. The sockaddr_in structures are declared in the routine and are on the stack. In fact, nothing in the program is yet in the heap. This is a mix of C and C++ with no objects declared or used up to this point.

This is the beginning odf the routine. There are several additional identical bits for other ports.

int      configureServer()
{
   sockaddr_in         servAddr; 

   memset(&servAddr, 0, sizeof(servAddr));
   servAddr.sin_family        = AF_INET;        
   servAddr.sin_port          = htons( g_tcpPorts[0].serverPort ); 
   servAddr.sin_addr.s_addr   = htonl(INADDR_ANY); 

   /* Create and initialize the TCP socket */
   if (( g_tcpPorts[0].serverSock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) < 0 )
   {
      PLOG( ERROR ) << "failed to acquire a socket for IO Control Server port:  " << g_tcpPorts[0].serverPort;
      return -1;     // caller will CloseAllPorts();
   } 

// ...........
}

So, my question is, how do I debug and track down the cause of these warnings.

Thanks,

4

2 回答 2

3

GDB 仍然不够完美,尤其是在调试 C++ 代码时。

在这种情况下,sockaddr_in是“普通旧数据”(没有任何 C++ 特性的 C 结构)。它不需要也不应该有任何虚拟表。如果 GDB 不这么认为,那就是 GDB 的问题。

在 GDB 错误数据库中打开了两个错误,这些错误非常准确(针对不同的结构/类)。除非它妨碍您的调试,否则我不会太担心它。

于 2012-04-19T13:24:29.387 回答
0

在包含声明 sockadd_in 结构的标头之前尝试使用 extern "C"。

extern "C"
{
#  include <netinet/in.h>
}

这可能会确保 sockaddr_in 没有或不需要 vtab。

于 2012-04-19T13:03:09.570 回答