使用stl_vector.h
在使用G ++编译我得到这个错误。我在Linux上。克++预期“(”令牌
{
if (max_size() - size() < __n)
__throw_length_error(__N(__s));
const size_type __len = size() + std::max(size(), __n); //THE ERROR IS ON THIS LINE!
return (__len < size() || __len > max_size()) ? max_size() : __len;
}
usr/include/c++/4.5/bits/stl_vector.h:1143:40: error: expected unqualified-id before
‘(’
token
我不知道之前不合格-ID为什么我“M收到这个错误,我寻觅了一番,发现一些‘相似’的问题,但我解决不了我的
编辑:所以这里的错误日志:
In file included from /usr/include/c++/4.5/vector:65:0,
from ../../RL_Toolbox/include/caction.h:34,
from ../../RL_Toolbox/include/cagent.h:35,
from shortestpathQLearning.cpp:42:
/usr/include/c++/4.5/bits/stl_vector.h:1143:40: error: expected unqualified-id before ‘(’ token
您可以在以前的错误日志“矢量”得到由标题“caction.h”像这样叫看:
//THESE ARE THE INCLUDES IN "caction.h"
#ifndef CACTION_H
#define CACTION_H
#include <stdio.h>
#include <vector> //HERE IT CALLS <vector>
#include <list>
#include <map>
#include "cbaseobjects.h"
然后调用矢量位/ stl_vector.h这样的:
#ifndef _GLIBCXX_VECTOR
#define _GLIBCXX_VECTOR 1
#pragma GCC system_header
#include <bits/stl_algobase.h>
#include <bits/allocator.h>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_vector.h>//HERE IT CALLS stl_vector.h
#include <bits/stl_bvector.h> //Im actually getting the exact same error from stl_vector.h on this header
只是从矢量(stl_vector和stl_bvector)的最后2个标题给我完全相同的错误,其余都是好的。有任何想法吗?
在此先感谢您的帮助。
你碰巧有个#define max或类似的地方吗? – user786653
只是猜测,但尝试删除常量。 – Dabbler
你是直接包含'stl_vector.h'还是包含'vector'头文件 –