使用gcc时,在头文件中查找定义的好方法是什么? [英] What is a good way to find definitions in header files when using gcc?

查看:160
本文介绍了使用gcc时,在头文件中查找定义的好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用gcc时,是否有人建议在头文件中查找定义? 使用MSVC时,我可以右键单击并选择转到定义",这确实很棒.

Does anyone have a recommended way to find definitions in header files when using gcc? When using MSVC, I can just right-click and select "Go to definition" which is really nice.

我使用过netbeans + gcc,它确实具有代码帮助,包括超链接到定义,因此这是一种选择.但是,我想知道是否还有其他具有该功能的IDE,以及不使用IDE时的最佳方法.

I have used netbeans + gcc, and it does have code assistance including hyperlinking to the definition, so that is one option. However, I would like to know if there are any other IDEs with that functionality and also the best way when not using an IDE.

推荐答案

您可以运行 Doxygen 生成基于HTML的源浏览器.这不需要使用Doxygen样式的文档对代码进行注释.它适用于多种语言,包括 C ++ Java Markdown (.md文件进入相关页面").

You can run Doxygen to generate an HTML-based source browser. This does not require that the code be annotated with Doxygen-style documentation. It works for multiple language, including C++, Java, and Markdown (.md files go to "Related Pages").

这是一种从命令行配置和启动Doxygen的方法(在Linux上经过测试)...

Here's a way of configuring and launching Doxygen from the command-line (tested on Linux)...

## basic
echo -e "SOURCE_BROWSER=YES\n EXTRACT_ALL=YES\n RECURSIVE=YES\n" |doxygen -
xdg-open html/index.html

## include diagrams and non-public content -- and launch browser immediately
echo -e "HAVE_DOT=YES\n CALL_GRAPH=YES\n CALLER_GRAPH=YES\n SOURCE_BROWSER=YES\n EXTRACT_ALL=YES\n EXTRACT_PRIVATE=YES\n EXTRACT_STATIC=YES\n RECURSIVE=YES\n SEPARATE_MEMBER_PAGES=YES\n GENERATE_LATEX=NO\n EXCLUDE_SYMLINKS=YES" |doxygen - && chromium-browser --new-window html/index.html

有一个名为 doxywizard 的配套程序,其中使您可以浏览许多可用于自定义生成的HTML的配置选项.或者,您可以运行doxygen -g来创建一个初始配置文件(包括详细的提示).

There is a companion program called doxywizard which lets you browse through the many configuration options available for customizing the generated HTML. Alternatively, you can run doxygen -g to create an initial configuration file (which includes detailed hints).

我建议使用以下非默认选项来生成源浏览器:

I recommend the following non-default options to generate a source browser:

SOURCE_BROWSER=YES ## display source code
EXTRACT_ALL=YES ## display all items (not just "documented" ones)
RECURSIVE=YES ## include source found in subdirectories
SEPARATE_MEMBER_PAGES=YES ## optional -- each class member has its own page

一旦打开了主页,就可以浏览到感兴趣的源(或使用搜索功能).来源通过指向相关声明的可点击链接进行交叉引用.

Once you have the main web page up, you can browse to the source of interest (or use the search feature). The source is cross-referenced with clickable links to relevant declarations.

我已经遇到过几次这个问题: doxygen可以创建非常长的文件名,并且Linux加密的主目录具有最多143个字符 .要变通解决此问题,您可能必须在屋外写html文件夹.

I've run into this problem a few times: doxygen can create really long filenames and Linux encrypted home directory has a limit of 143 characters. To work around this, you may have to write the html folder outside of your home.

一种快速而肮脏的解决方案是将html链接到/tmp/dev/shm中的文件夹-也许还chmod授予权限以提高数据安全性.

A quick and dirty solution is to link html to a folder in /tmp or /dev/shm -- maybe also chmoding the permissions for better data security.

这篇关于使用gcc时,在头文件中查找定义的好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆