compiler error expected nested-name specifier

人走茶凉 提交于 2019-12-05 12:02:12

GCC 4.6.3 doesn't support C++11 type aliases: using handler_t1 = bool (*)(except::Logic const&);. Non-template type aliases are equivalent to typedefs: typedef bool (*handler_t1)(except::Logic const&);. Replace them and see if that helps.

Or even better, upgrade to a more recent compiler version. I believe the regular responders here tend to write to the portion of the language compiled by GCC 4.8.

EDIT: The only other iffy feature I see in that answer is range-based-for, which I believe GCC added support for in 4.6. You should be OK after replacing the type aliases with typedefs.

With g++ before version 6 you need the option --std=c++11 to be able to use the using directive.

I also got the same problem and it solved by just upgrading go G++ 4.8 in my Ubuntu.

I assume that you already have a former version of gcc, the easiest way could be adding PPA to your repositories and Update and upgrade you can have the latest version with no worries:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

sudo apt-get update

this will add the new PPA to the other sources.

Then unistall the alternative:

sudo update-alternatives --remove-all gcc

sudo update-alternatives --remove-all g++

then:

sudo apt-get install gcc-4.8

sudo apt-get install g++-4.8

and as the alternative packages install :

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20

sudo update-alternatives --config gcc

sudo update-alternatives --config g++

at the end:

sudo apt-get update

sudo apt-get upgrade -y

sudo apt-get dist-upgrade

Hope this changes the --version ;)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!