우분투 가상 환경에서 터미널을 사용하여 Linux를 처음 사용합니다. 나는 무엇이 왜 이러한 오류가 발생하는지 파악할 수 없으며, 누락 된 ''와 일치하지 않는 것처럼 보입니다. 또는 #define 충돌. 나는 키 문제는 인덱스 키를 구성지도의 선언과 초기화에 생각지도 유형을 사용하면 gcc 오류가 발생합니다 : 'for'앞에 부적합 ID가 있어야합니다.
my_predictor.h:82:42: error: template argument 2 is invalid
my_predictor.h:82:42: error: template argument 4 is invalid
my_predictor.h:84:9: error: expected unqualified-id before ‘for’
my_predictor.h:84:23: error: ‘g’ does not name a type
my_predictor.h:84:44: error: ‘g’ does not name a type
my_predictor.h:91:42: error: template argument 2 is invalid
my_predictor.h:91:42: error: template argument 4 is invalid
my_predictor.h:93:9: error: expected unqualified-id before ‘for’
my_predictor.h:93:23: error: ‘f’ does not name a type
my_predictor.h:93:39: error: ‘f’ does not name a type
my_predictor.h: In member function ‘virtual branch_update* local_predictor::predict(branch_info&)’:
my_predictor.h:107:57: error: invalid types ‘int[int]’ for array subscript
my_predictor.h:111:40: error: invalid types ‘int[int]’ for array subscript
my_predictor.h: In member function ‘virtual void local_predictor::update(branch_update*, bool, unsigned int)’:
my_predictor.h:121:62: error: invalid types ‘int[int]’ for array subscript
my_predictor.h:124:46: error: invalid types ‘int[int]’ for array subscript
my_predictor.h:125:33: error: invalid types ‘int[int]’ for array subscript
my_predictor.h:127:41: error: invalid types ‘int[int]’ for array subscript
my_predictor.h:128:29: error: invalid types ‘int[int]’ for array subscript
my_predictor.h:131:33: error: invalid types ‘int[int]’ for array subscript
my_predictor.h:132:30: error: invalid types ‘int[int]’ for array subscript
my_predictor.h:135:33: error: invalid types ‘int[int]’ for array subscript
my_predictor.h:136:30: error: invalid types ‘int[int]’ for array subscript
한 다음 A A 비트 세트 객체 인 : 여기
내가 GCC 컴파일러에서 얻을 오류입니다 비트 문자열. 그것은 array [] 연산 (cplusplus.com/reference/map 사이트에서 찾은 것으로부터 유효하다고 가정 됨)과 함께 나중의 오류를 만드는 것으로 보입니다.1:// my_predictor.h
// This file contains a sample gshare_predictor class.
// It is a simple 32,768-entry gshare with a history length of 15.
5:#include <bitset>
#include <map>
7:using namespace std;
64:class local_predictor : public branch_predictor {
65:public:
#define LHBITLEN 10
#define PREDCNTR 2
#define LOCHISTTABLERNG 4096
#define LOCPREDRNG 1024
70: local_update u;
branch_info bcopy;
// otherwise ints, where each will be multiplied by 10, then add 1 if taken/true. Initial test case to change if 10 bits long already
75: // ?correct location? Bit array of length 10 for local history table value entries
bitset<LHBITLEN> lhthistval;
bitset<PREDCNTR> lpcounter;
// initialize to 0's
80: // lhthistval.reset();
std::map<int, (bitset<LHBITLEN>) > lochisttab;
//map<int, (bitset<10>) > lht;
for (int g=0; g < LOCHISTTABLERNG; g++) {
85: //const int j = g;
lochisttab[g] = lhthistval.reset();
//lht.insert(pair<int, (bitset<LHBITLEN>)>(j, lhthistval.reset()));
}
90:
std::map<int, (bitset<PREDCNTR>) > locprediction;
//map<int, (bitset<2>) > locpredict;
for (int f=0; f < LOCPREDRNG; f++) {
//const int j = f;
95: //locpredict.insert(pair<int, (bitset<PREDCNTR>)>(j,lpcounter.reset()));
locprediction[f] = lpcounter.reset();
}
100: local_predictor (void) {
}
branch_update *predict (branch_info & b) {
bcopy = b;
105: // address for locpredict based on value by modulus (remainder) of branch address divide by 4096
int braddr = static_cast<int>(b.address % LOCHISTTABLERNG);
bitset<LHBITLEN> address = lochisttab[braddr];
// safe and compiler allow since it is only 10 bits long max?
int indx = static_cast<int>(address.to_ulong());
110: // use the MSB or Pos 1 in 2 bit array to set boolean Take/Don't
bool take = locprediction[indx].test(1);
u.direction_prediction (take);
u.target_prediction (0);
return &u;
115: }
void update (branch_update *u, bool taken, unsigned int target) {
if (bcopy.br_flags & BR_CONDITIONAL) {
120: int lhtaddress = bcopy.address % LOCHISTTABLERNG;
bitset<LHBITLEN> addr = lochisttab[lhtaddress];
int indx = static_cast<int>(addr.to_ulong());
for (int i=1; i < LHBITLEN; i++) {
bool prval = lochisttab[lhtaddress].test(i-1);
125: lochisttab[lhtaddress].set(i,prval);
}
bool prev = locprediction[indx].test(0);
locprediction[indx].set(1,prev);
130: if (taken) {
lochisttab[lhtaddress].set(0);
locprediction[indx].set(0);
}
else {
135: lochisttab[lhtaddress].reset(0);
locprediction[indx].reset(0);
}
}
}
};
편집 :
여기 내 코드입니다 내가 원래지도 선언에 대한 비트 세트 인수 주위에 괄호 없었다. 컴파일러는 "for 'before for unqualified-id'의 첫 번째 오류를 제공했습니다. 템플릿 인수 오류는 괄호에서 나온 것입니다 (하지만 결국 비트 셋 데이터 유형을 잠재적으로 이해했기 때문에 결과라고 생각했습니다).
당신은 괄호 유형을 넣을 수 없습니다. – leemes
당신은 어떤 함수 밖에서도 for 문을 갖고있는 것처럼 보입니다. –
"오류 : 예상 unqualified-id before 'for'"오류가 발생하는 것에 실제로 응답하여 괄호를 추가했습니다. parantheses는 잘못된 인수의 새로운 오류를 만들었습니다. –