问题描述
Ubuntu 10.04 32位,eclipse,C和C ++我有一个使用select()监视一堆TCP和UDP端口的程序。我使用 sockaddr_in 结构以通常的方式(socket(),bind(),listen(),accept()等)创建这些端口。
程序在命令行中工作正常。当我注意到以下警告时,我正在使用eclipse调试器修复一个错误(修复了!):
warning:can'找到'sockaddr_in'值的虚拟表的链接符号
warning:找到`operator delete(void *)'而不是
嗯,修复我的错误后,我检查了警告持续。
我知道当我进入我的ConfigureServer()例程,其中ports / socket连接时,警告开始。 sockaddr_in结构在例程中声明,并在堆栈中。实际上,程序中还没有任何内容。这是C和C ++的混合,在这一点上没有声明或使用任何对象。
这是例程的开始odf。其他端口还有几个相同的位。
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);
/ *创建并初始化TCP套接字* /
if((g_tcpPorts [0] .serverSock = socket(AF_INET,SOCK_STREAM,IPPROTO_IP))< 0)
{
PLOG(ERROR)<< 无法获取IO Control Server端口的套接字:<< g_tcpPorts [0] .serverPort;
return -1; //调用者将CloseAllPorts();
}
// ...........
}
所以,我的问题是,如何调试和跟踪这些警告的原因。
谢谢,
GDB还不太完美,特别是在调试C ++代码时。
在这种情况下, sockaddr_in
是纯旧数据(没有任何C ++功能的C结构)。它不需要,也不应该有任何虚拟表。如果GDB认为是GDB的问题。
(对于不同的结构体/类)。我不会担心它太多,除非它阻碍你的调试。
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,
GDB is still less than perfect, especially when it comes to debugging C++ code.
In this case, sockaddr_in
is "plain old data" (a C struct without any C++ features). It does not need and should not have any virtual table. If GDB thinks otherwise, that's a problem with GDB.
There are two bugs open in GDB bug database that quite this exact message (for different structs/classes). I would not worry about it too much unless it gets in the way of your debugging.
这篇关于如何处理这个Linux C ++警告? “找不到用于”sockaddr_in“的虚拟表的链接器符号”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!