C ++头中的循环依赖性。怎么找? [英] Circular dependency in C++ headers. How To Find?

查看:340
本文介绍了C ++头中的循环依赖性。怎么找?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想你都知道什么是标题中的循环依赖。
其结果通常如下:

I suppose you all know what is circular dependency in headers. The result of it usually are like the following:

错误:'MyClass'未在此范围内声明

error: 'MyClass' was not declared in this scope

如果程序很短,就清楚该怎么做。
但是如果程序有几十个文件...

If the program is short it is clear what to do. But if the program has tens of files...

我的问题是是否有一些算法
我的意思是一些特定的步骤,它带给你成功,不只是看看代码,直到你找到它。

My question is "Is there some algorithm to find the circular dependency?" I mean some certain steps, which bring you to success, not just "look into the code until you found it".

可能是一些程序,

推荐答案

至少我知道一个编译器(Visual C ++)有一个名为show includes的选项,跟踪包含订单。这可以帮助你找出循环发生的地方。如果你的编译器没有这样的选项,你可以添加#pragma消息(或等效的)到文件的开头跟踪它。

At least one compiler I know of (Visual C++) has an option called "show includes" that helps you track the include order. That can help you find out where the cycle occurs. If your compiler doesn't have such an option, you can add #pragma message (or equivalent) to the beginning of your files to trace it.

这篇关于C ++头中的循环依赖性。怎么找?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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