在linux上读取c程序时如何找到结构的定义?

前端之家收集整理的这篇文章主要介绍了在linux上读取c程序时如何找到结构的定义?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在阅读xl2tpd的源代码,并在阅读此代码时遇到很多问题.例如,我找不到结构lac的定义.我如何找到这个结构的定义?

我使用ctags和vim来读取此代码,但未能找到结构.我用Google搜索,找不到结构.有没有什么方法可以让代码阅读过程更舒服?也就是说,我可以跳到大多数变量,函数和结构的定义?

解决方法

用vim试试cscope.按照以下步骤 –
1)在xl2tpd目录中运行cscope -R.它将创建文件cscope.out
2)使用vim打开文件,其中使用结构lac
3)使用:cs f g< lac> .现在它将显示定义lac的文件.
4)选择file.h.它包含定义.
如果您对struct lac的定义非常感兴趣,那么它是 –
  1. struct lac
  2. {
  3. struct lac *next;
  4. struct host *lns; /* LNS's we can connect to */
  5. struct schedule_entry *rsched;
  6. int tun_rws; /* Receive window size (tunnel) */
  7. int call_rws; /* Call rws */
  8. int rxspeed; /* Tunnel rx speed */
  9. int txspeed; /* Tunnel tx speed */
  10. int active; /* Is this connection in active use? */
  11. int hbit; /* Permit hidden AVP's? */
  12. int lbit; /* Use the length field? */
  13. int challenge; /* Challenge authenticate the peer? */
  14. unsigned int localaddr; /* Local IP address */
  15. unsigned int remoteaddr; /* Force remote address to this */
  16. char authname[STRLEN]; /* Who we authenticate as */
  17. char password[STRLEN]; /* Password to authenticate with */
  18. char peername[STRLEN]; /* Force peer name to this */
  19. char hostname[STRLEN]; /* Hostname to report */
  20. char entname[STRLEN]; /* Name of this entry */
  21. int authpeer; /* Authenticate our peer? */
  22. int authself; /* Authenticate ourselves? */
  23. int pap_require; /* Require PAP auth for PPP */
  24. int chap_require; /* Require CHAP auth for PPP */
  25. int pap_refuse; /* Refuse PAP authentication for us */
  26. int chap_refuse; /* Refuse CHAP authentication for us */
  27. int idle; /* Idle timeout in seconds */
  28. int autodial; /* Try to dial immediately? */
  29. int defaultroute; /* Use as default route? */
  30. int redial; /* Redial if disconnected */
  31. int rmax; /* Maximum # of consecutive redials */
  32. int rtries; /* # of tries so far */
  33. int rtimeout; /* Redial every this many # of seconds */
  34. char pppoptfile[STRLEN]; /* File containing PPP options */
  35. int debug;
  36. struct tunnel *t; /* Our tunnel */
  37. struct call *c; /* Our call */
  38. };

猜你在找的Linux相关文章