了解一个函数是否在C ++项目中调用? [英] Find out if a function is called within a C++ project?

查看:77
本文介绍了了解一个函数是否在C ++项目中调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从C ++项目中删除未使用的函数。

I'm trying to remove functions that are not used from a C++ project. Over time it's become bloated and I'm looking to remove functions that aren't used at all.

我有一个解决方案文件在Visual Studio中的所有项目,但是,我使用cmake,所以我可以生成项目文件的另一个IDE,如果必要的(这就是为什么这没有用visual-studio标记)。

I have all the projects in a solution file in Visual Studio, but I use cmake so I can generate project files for another IDE if necessary (which is why this isn't tagged with visual-studio).

这样的东西是否存在?在哪里它将分析源并告诉我哪些函数不被调用。我在这里看到PC-Lint在一些问题中提到,但是似乎没有这样做。

Does something like this exist? Where it'll analyze the source and tell me which functions are not called. I saw PC-Lint mentioned in a few questions here, but that doesn't seem to do this.

我真正想做的是调用查找所有引用

What I really want to do is call "Find all references" on each function and remove the functions not called, but doing this manually would take much too long.

推荐答案

使用 __ declspec(deprecated)前面的函数声明你想摆脱。如果该函数在编译时实际使用,那么将抛出编译警告。

Use __declspec(deprecated) in front of the function declaration you want to get rid of. That will throw up compile warnings if that function is actually used at compile time.

这篇关于了解一个函数是否在C ++项目中调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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