连接器问题与静态const类成员有关 [英] Weird linker problem with static const class members

查看:178
本文介绍了连接器问题与静态const类成员有关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我,为什么 gcc 链接器会给我以下错误:test_class :: test_struct :: constVar,引用自:__ZN12lu_test_class27test_struct6constVar $ test_class.o中的non_lazy_ptr

Please tell me, why gcc linker gives me the following error: "test_class::test_struct::constVar", referenced from: __ZN12lu_test_class27test_struct6constVar$non_lazy_ptr in test_class.o ?

我的代码( test_class.h ):

class test_class
{
    struct test_struct
    {
         static const int constVar = 0;
    };
};

constVar 的所有引用都位于 test_class 通常的静态成员访问形式的范围: test_struct :: constVar

All references to constVar are in test_class scope in a usual static member access form: test_struct::constVar.

推荐答案

const int test_class::test_struct::constVar;

对我有用。

这篇关于连接器问题与静态const类成员有关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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