在')之前预期的初级表达gcc 7.1

时间:2017-10-19 14:25:48

标签: c++ gcc

使用下面的代码,我从一个巨大的项目中扣除了有问题的部分,用 gcc 7.1 给我预期的初级表达式错误,而它编译我,例如,< strong> gcc&lt; = 6.1 (我之间的版本尚未尝试)。

也许是因为一些新的定义,但我找不到它。

以下是代码:

basesm.h

#ifndef BASESM_H
#define BASESM_H

#include "statemachine.h"

class IEVD
{
};

template<U16 SIZE>
class CEventDispatcher : public IEVD
{
    public:
        template<U16 INDEX> IState* GSM(void) { return _xSM.GSM<INDEX>(); }
        CRootSM<SIZE>       _xSM;
};

#endif // BASESM_H

statemachine.h

#ifndef STATEMACHINE_H
#define STATEMACHINE_H

#include "types.h"

class IState
{
    public:
        IState(void)
        {
        }
};

class CState : public IState
{
    public:
};

template<U16 SIZE> class CRootSM
{
    public:
        CRootSM(void) : _xStates()
        {
            for(U16 u16State = 0; u16State < SIZE; ++ u16State)
            {
                _xStates[u16State] = new CState();
            }
        }

        template<U16 INDEX>
        IState* GSM(void)
        {
            static_assert(INDEX < SIZE, "Index overrun.");

            return _xStates[INDEX];
        }

        IState*             _xStates[SIZE];
};

#endif // STATEMACHINE_H

types.h中

#ifndef TYPES_H
#define TYPES_H

typedef unsigned short U16;

#endif // TYPES_H

winnetwork.cpp

#include "basesm.h"
#include "statemachine.h"

的main.cpp

int main()
{
    return 0;
}

错误:

error: expected primary-expression before ')' token
     template<U16 INDEX> IState* GSM(void) { return _xSM.GSM<INDEX>(); }

0 个答案:

没有答案