When I’m reproducing the code from a paper, I encountered CPLEX for the first time. I followed the methods provided in the CPLEX documentation to set up the necessary libraries and compilation options. However, when running the code, I encountered an error indicating an undeclared identifier. The output information is as follows:
Build started at 9:50...
1>------ Build started: Project: replication-adapt-cmsa+la-vs-v1, Configuration: Release x64 ------
1>main.cpp
1>C:Program FilesIBMILOGCPLEX_Studio128concertincludeilconcertiloiterator.h(88,17): error C2065: 'ext': undeclared identifier
1>(compiling source file 'main.cpp')
1>C:Program FilesIBMILOGCPLEX_Studio128concertincludeilconcertiloiterator.h(88,17):
1>the template instantiation context (the oldest one first) is
1> C:Program FilesIBMILOGCPLEX_Studio128concertincludeilconcertiloiterator.h(94,2):
1> see reference to class template instantiation 'IloIterator<E>' being compiled
1>C:Program FilesIBMILOGCPLEX_Studio128concertincludeilconcertiloiterator.h(88,27): warning C4346: 'ImplClass': dependent name is not a type
1>(compiling source file 'main.cpp')
1>C:Program FilesIBMILOGCPLEX_Studio128concertincludeilconcertiloiterator.h(88,27): error C2061: syntax error: identifier 'ImplClass'
1>(compiling source file 'main.cpp')
1>C:Program FilesIBMILOGCPLEX_Studio128concertincludeilconcertiloiterator.h(91,25): error C2065: 'ext': undeclared identifier
1>(compiling source file 'main.cpp')
1>C:Program FilesIBMILOGCPLEX_Studio128concertincludeilconcertiloiterator.h(91,14): warning C4346: 'ImplClass': dependent name is not a type
1>(compiling source file 'main.cpp')
1>C:Program FilesIBMILOGCPLEX_Studio128concertincludeilconcertiloiterator.h(91,14): error C2061: syntax error: identifier 'ImplClass'
1>(compiling source file 'main.cpp')
1>D:_Master0Adapt_cmsa_mdmwnppreplication-adapt-cmsa+la-vs-v1replication-adapt-cmsa+la-vs-v1main.cpp(84,12): warning C4244: 'argument': conversion from 'time_t' to 'unsigned int', possible loss of data
1>D:_Master0Adapt_cmsa_mdmwnppreplication-adapt-cmsa+la-vs-v1replication-adapt-cmsa+la-vs-v1main.cpp(751,17): warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data
1>Done building project "replication-adapt-cmsa+la-vs-v1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 9:50 and took 02.923 seconds ==========
There’s another error shows that error C2061: Syntax error: identifier “ImplClass”
The codes in iloiterator.h
from line 1 to line 91 are shown as follows:
// -------------------------------------------------------------- -*- C++ -*-
// File: ./include/ilconcert/iloiterator.h
// --------------------------------------------------------------------------
// Licensed Materials - Property of IBM
//
// 5725-A06 5725-A29 5724-Y47 5724-Y48 5724-Y49 5724-Y54 5724-Y55 5655-Y21
// Copyright IBM Corp. 2000, 2013
//
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with
// IBM Corp.
// ---------------------------------------------------------------------------
#ifndef __CONCERT_iloiteratorH
#define __CONCERT_iloiteratorH
#ifdef _WIN32
#pragma pack(push, 8)
#endif
#include <ilconcert/iloextractable.h>
class IloBaseIterator {
private:
IloEnvI* _env;
class IloTypedList* _list;
class IloTypedList* _current;
IloBool _withSubClasses;
public:
IloBaseIterator(const IloEnv env, IloBool withSubClasses = IloTrue)
: _env(env.getImpl())
, _list(0)
, _current(0)
, _withSubClasses(withSubClasses)
{}
void goToNextNonEmptyList(IloLinkedList<IloExtractableI>::Iterator& _iter);
void init(IloRtti::TypeInfo typeInfo, IloLinkedList<IloExtractableI>::Iterator &_iter);
};
template <class E>
class IloIterator : public IloBaseIterator {
private:
IloExtractableList::Iterator _iter;
#if defined(ILO_HP_aCC) || defined(ILO_LINUX) || defined(ILO_APPLE)
typedef typename E::ImplClass EImplClass;
#endif
void init() {
#if defined(ILO_HP_aCC) || defined(ILO_LINUX) || defined(ILO_APPLE)
IloBaseIterator::init(EImplClass::GetTypeInfo(), _iter);
#else
IloBaseIterator::init(E::ImplClass::GetTypeInfo(), _iter);
#endif
}
public:
IloIterator(const IloEnv env, IloBool withSubClasses = IloTrue)
: IloBaseIterator(env,withSubClasses),
_iter(IloExtractableList())
{
init();
}
IloBool ok() { return _iter.ok(); }
void operator++() {
++_iter;
if (!_iter.ok()) { IloBaseIterator::goToNextNonEmptyList(_iter); }
}
E operator*() {
#if defined(ILO_HP_aCC) || defined(ILO_LINUX) || defined(ILO_APPLE)
EImplClass* ext = (EImplClass*)*_iter;
IloAssert(ext->isType(EImplClass::GetTypeInfo()),
"Bad extractable type in IloKindOfIterator::operator*");
return (EImplClass*)ext;
#elif defined(ILO_RS6000)
typename E::ImplClass *ext = (typename E::ImplClass*)*_iter;
IloAssert(ext->isType(E::ImplClass::GetTypeInfo()),
"Bad extractable type in IloKindOfIterator::operator*");
return (typename E::ImplClass*)ext;
#else
E::ImplClass* ext = (E::ImplClass*)*_iter;
IloAssert(ext->isType(E::ImplClass::GetTypeInfo()),
"Bad extractable type in IloKindOfIterator::operator*");
return (E::ImplClass*)ext;
#endif
}
};
I’m confused with these two errors.