简体   繁体   English

timer_create和timer_settime生成分段错误

[英]timer_create and timer_settime generating segmentation fault

I am creating a timer. 我正在创建一个计时器。 The structure is: 结构为:

struct my_timer
{
  unsigned int ip_address;
  timer_t timer;
};

Now ip_address is initialized. 现在, ip_address已初始化。

After that when I try to create timer via "timer_create", it's throwing segmentation fault . 之后,当我尝试通过“ timer_create”创建计时器时,将引发分段错误。

If I don't initialize ip_address before and then create the timer then timer is getting created successfully. 如果我之前未初始化ip_address ,然后创建了计时器,则计时器创建成功。

Can anyone help here, as to why its happening? 任何人都可以在这里提供帮助,以了解其发生原因吗?

Basically I want ip_address to find which timer has to be stopped later. 基本上,我希望ip_address查找稍后必须停止的计时器。

As documented , timer_create(2) does not take any sort of argument containing an IP address, nor a structure containing a timer_t plus a user-specified other part. 文档所述timer_create(2)不会接受包含IP地址的任何类型的参数,也不会包含包含timer_t以及用户指定的其他部分的结构。

Do you have compiler warnings enabled? 您是否启用了编译器警告? I imagine you are simply calling these functions with inappropriate arguments, but without seeing your code there's no way to know for sure. 我想您只是在使用不适当的参数调用这些函数,但是却看不到您的代码,因此无法确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM