C ++ Error: Expected primary expression before ‘[’ token

Now I’m trying to install RealPlexor by dklab, but it’s falls with errors:

# bash ./Make.sh
In file included from dklab_realplexor.cpp:68:
utils/misc.h: In function ‘void die(std::string)’:
utils/misc.h:105: error: expected primary-expression before ‘[’ token
compilation terminated due to -Wfatal-errors.

Here is that line

s = regex_replace(s, regex("\$!"), [](smatch s) { return strerrno(); });

Make sure that you are passing the following flag to your compiler (as described in the the g++ documentation


This tells the gcc compiler (g++) to compile your code with C++11 semantics.

The lambda expression syntax you are using (the part starting with []
) is a C++11 feature, and will cause compilers great confusion if it appears in code that they aren’t expecting to be C++11.

However, as has been pointed out in another comment here (and is confirmed by this table
, the version of gcc you are running (4.4.5, per a comment) doesn’t have lambda expression support. May have to use a function object instead, or upgrade to a newer version of gcc/g++.

Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » C ++ Error: Expected primary expression before ‘[’ token

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录