MSVC C4100:“应用程序":未引用的形式参数警告 [英] MSVC C4100: 'application' : unreferenced formal parameter warning
本文介绍了MSVC C4100:“应用程序":未引用的形式参数警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码在使用 MSVC 编译时生成 C4100 警告.这怎么可能?显然是引用了应用程序".
The following code generates a C4100 warning when compiling using MSVC. How is this possible? "appliation" is clearly being referenced.
class ApplicationInfo : public QObject
{
Q_OBJECT
public:
...
static void initialize(QApplication &application);
...
...
}
void ApplicationInfo::initialize(QApplication &application)
{
application.setOrganizationName(ApplicationInfo::organizationName());
application.setOrganizationDomain(ApplicationInfo::organizationName());
application.setApplicationName(ApplicationInfo::applicationName());
application.setApplicationVersion(ApplicationInfo::applicationVersion().toString());
}
推荐答案
您使用 application
对象调用的函数是静态函数,因此它们并没有真正引用 application
对象.
The functions you are calling using the application
object are static functions, so they aren't really referencing the application
object.
setOrganizationName
setOrganizationDomain
setApplicationName
setApplicationVersion
是 QCoreApplication
派生自的 QCoreApplication
的所有静态成员.使用 application
引用仅解析这些函数的名称范围,但实际上并未使用该对象.
Are all static members of QCoreApplication
which QApplication
derives from. Using the application
reference only resolves the name scoping for these functions, but the object isn't actually used.
这篇关于MSVC C4100:“应用程序":未引用的形式参数警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文