MSVC C4100: 'application' : unreferenced f

2019-06-24 03:40发布

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());
}

1条回答
Emotional °昔
2楼-- · 2019-06-24 04:09

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

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.

查看更多
登录 后发表回答