cudd — ошибка компиляции C ++: ожидаемый неквалифицированный идентификатор перед токеном ‘{’

Я использую:

g++ -std=c++0x

компилятор
Я разрабатываю какой-то проект с использованием пакета Cudd http://vlsi.colorado.edu/~fabio/CUDD/ и я хотел кешировать некоторые результаты, так что вот мой кеш код C ++

lrucache.h

#ifndef __LRUCACHE_H_
#define __LRUCACHE_H_

#include <iostream>//=> line 4
#include <vector>
#include <unordered_map>
#include "cudd.h"
using namespace std;struct LRUCacheEntry
{
unsigned int key;
DdNode * data;
LRUCacheEntry* prev;
LRUCacheEntry* next;
};class LRUCache
{
private:
std::unordered_map<unsigned int, LRUCacheEntry *> _mapping;
vector<LRUCacheEntry *> _freeEntries;
LRUCacheEntry *head;
LRUCacheEntry *tail;
LRUCacheEntry *entries;
DdManager *nfaobdd_manager;

public:
LRUCache(size_t size, DdManager *nfaobdd_manager_ref);
~LRUCache();

void put(unsigned int key, DdNode * data);

DdNode * get(unsigned int key);

private:
void detach(LRUCacheEntry* node);

void attach(LRUCacheEntry* node);

};

#endif /*__LRUCACHE_H_*/

lrucache.c

#include <lrucache.h> //=>line 1LRUCache::LRUCache(size_t size, DdManager *nfaobdd_manager_ref)
{

entries = new LRUCacheEntry[size];

for (int i=0; i<size; i++)
_freeEntries.push_back(entries+i);

head = new LRUCacheEntry;
tail = new LRUCacheEntry;
head->prev = NULL;
head->next = tail;
tail->next = NULL;
tail->prev = head;

nfaobdd_manager = nfaobdd_manager_ref;
}

LRUCache::~LRUCache()
{
LRUCacheEntry* node = head->next;
while(node!=tail){

Cudd_RecursiveDeref(nfaobdd_manager,node->data);
}
delete head;
delete tail;
delete [] entries;
}

void LRUCache::put(unsigned int key, DdNode * data)
{
Cudd_ref(data);

LRUCacheEntry* node = _mapping[key];
if(node)
{
// refresh the link list
detach(node);
node->data = data;
attach(node);
}
else{
if ( _freeEntries.empty() )
{
node = tail->prev;
detach(node);
_mapping.erase(node->key);
Cudd_RecursiveDeref(nfaobdd_manager,node->data);
node->data = data;
node->key = key;
_mapping[key] = node;
attach(node);
}
else{
node = _freeEntries.back();
_freeEntries.pop_back();
node->key = key;
node->data = data;
_mapping[key] = node;
attach(node);
}
}
}DdNode * LRUCache::get(unsigned int key)
{
LRUCacheEntry* node = _mapping[key];
if(node)
{
detach(node);
attach(node);
return node->data;
}
else return NULL;
}void LRUCache::detach(LRUCacheEntry* node)
{
node->prev->next = node->next;
node->next->prev = node->prev;
}
void LRUCache::attach(LRUCacheEntry* node)
{
node->next = head->next;
node->prev = head;
head->next = node;
node->next->prev = node;
}

nfaobdd.h

#ifndef __NFAOBDD_H_
#define __NFAOBDD_H_
.
.
#include <lrucache.h>//=>line 69
.
.
class NFAOBDD{
.
.
LRUCache *lrucache;
.
}
#endif /*__NFAOBDD_H_*/

nfaobdd.c

#include "nfaobdd.h" //=>line 10
.
.
lrucache = new LRUCache(100, manager);
.
.
/*character is of type unsigned int*/
DdNode * char_BDD = lrucache->get(character);
if(!char_BDD){
/*calculate the value for char_BDD*/
char_BDD = convert_decimal_to_BDD(character, manager, input_char);
/*cache the calculated value*/
lrucache->put(character, char_BDD);
}
.
.
delete lrucache;

Когда я использую этот кеш в своем проекте, я получаю следующую ошибку, которую не могу понять.
Я ценю любую помощь

In file included from /usr/include/c++/4.6/ios:45:0,
from /usr/include/c++/4.6/ostream:40,
from /usr/include/c++/4.6/iostream:40,
from /home/nadaossama/Dropbox/Master_Project/regex/regex/lrucache.h:4,
from nfaobdd.h:69,
from nfaobdd.c:10:
/usr/include/c++/4.6/bits/basic_ios.h: At global scope:
/usr/include/c++/4.6/bits/basic_ios.h:193:7: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/basic_ios.h:194:7: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/basic_ios.h: In member function ‘std::basic_ios<_CharT, _Traits>::operator void*() const’:
/usr/include/c++/4.6/bits/basic_ios.h:114:22: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/basic_ios.h:114:22: error: expected ‘;’ before ‘{’ token
/usr/include/c++/4.6/bits/basic_ios.h:114:22: error: expected primary-expression before ‘)’ token
/usr/include/c++/4.6/bits/basic_ios.h:114:29: error: expected primary-expression before ‘?’ token
/usr/include/c++/4.6/bits/basic_ios.h: In member function ‘bool std::basic_ios<_CharT, _Traits>::operator!() const’:
/usr/include/c++/4.6/bits/basic_ios.h:118:22: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/basic_ios.h:118:22: error: expected ‘;’ before ‘{’ token
/usr/include/c++/4.6/bits/basic_ios.h:118:22: error: expected primary-expression before ‘)’ token
In file included from /usr/include/c++/4.6/ostream:588:0,
from /usr/include/c++/4.6/iostream:40,
from /home/nadaossama/Dropbox/Master_Project/regex/regex/lrucache.h:4,
from nfaobdd.h:69,
from nfaobdd.c:10:
/usr/include/c++/4.6/bits/ostream.tcc: In member function ‘std::basic_ostream<_CharT, _Traits>::pos_type std::basic_ostream<_CharT, _Traits>::tellp()’:
/usr/include/c++/4.6/bits/ostream.tcc:244:15: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/ostream.tcc:244:15: error: expected ‘)’ before ‘{’ token
/usr/include/c++/4.6/bits/ostream.tcc: In member function ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::seekp(std::basic_ostream<_CharT, _Traits>::pos_type)’:
/usr/include/c++/4.6/bits/ostream.tcc:265:15: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/ostream.tcc:265:15: error: expected ‘)’ before ‘{’ token
/usr/include/c++/4.6/bits/ostream.tcc: In member function ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::seekp(std::basic_ostream<_CharT, _Traits>::off_type, std::ios_base::seekdir)’:
/usr/include/c++/4.6/bits/ostream.tcc:297:15: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/ostream.tcc:297:15: error: expected ‘)’ before ‘{’ token
In file included from /usr/include/c++/4.6/istream:859:0,
from /usr/include/c++/4.6/iostream:41,
from /home/nadaossama/Dropbox/Master_Project/regex/regex/lrucache.h:4,
from nfaobdd.h:69,
from nfaobdd.c:10:
/usr/include/c++/4.6/bits/istream.tcc: In member function ‘std::basic_istream<_CharT, _Traits>::pos_type std::basic_istream<_CharT, _Traits>::tellg()’:
/usr/include/c++/4.6/bits/istream.tcc:829:19: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/istream.tcc:829:19: error: expected ‘)’ before ‘{’ token
/usr/include/c++/4.6/bits/istream.tcc: In member function ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::seekg(std::basic_istream<_CharT, _Traits>::pos_type)’:
/usr/include/c++/4.6/bits/istream.tcc:859:19: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/istream.tcc:859:19: error: expected ‘)’ before ‘{’ token
/usr/include/c++/4.6/bits/istream.tcc: In member function ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::seekg(std::basic_istream<_CharT, _Traits>::off_type, std::ios_base::seekdir)’:
/usr/include/c++/4.6/bits/istream.tcc:898:19: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.6/bits/istream.tcc:898:19: error: expected ‘)’ before ‘{’ token

-3

Решение

Пакет Cudd требует как минимум #include «util.h» и #include «cudd.h». После добавления #include «util.h» в lrucahe.h проблема была решена

Спасибо за вашу помощь

0

Другие решения


По вопросам рекламы [email protected]