0

I have an old MFC based C++ project that I am trying to compile with g++ in eclipse on Linux (Centos 6.2). I'm getting the following errors from header files:

RawData.h:54: error: expected template-name before ‘<’ token
RawData.h:54: error: expected ‘{’ before ‘<’ token
RawData.h:54: error: expected unqualified-id before ‘<’ token

Here is the part of the header file with the problem (starting with line 54):

class CRawDayData: public CArray<CRawQHData*,CRawQHData*>
{
public:
    CRawDayData();
    virtual ~CRawDayData();

public:
    tm m_tmDate;

};

I'm thinking the issue has something to do with the CArray since I'm on Linux and not using MFC's afx stuff. Any thoughts?

reuben
  • 3,360
  • 23
  • 28
user1502835
  • 271
  • 1
  • 2
  • 6
  • The compiler simply doesn't know what `CArray` is, hence the error messages. If it is a "MFC based" project, as you stated yourself, then you are going to need MFC on Linux. `CArray` is part of MFC. So, what were you planning to do about it? Port MFC to Linux? – AnT stands with Russia Jul 05 '12 at 04:15
  • Yes, I'm porting Windows program to Linux. I just need Linux equiv to CArray, and proper syntax for header file. Leaning towards STL std::vector. – user1502835 Jul 05 '12 at 20:02

2 Answers2

2

If that is the only error you get, I would suggest replacing CArray with its STL equivalent std::vector. If MFC or windows API's are used extensively, better try compiling it against Winelib.

Refer: Run MFC Program on Linux

using STL, you can write like this:

#include<vector>

class CRawDayData: public vector<CRawQHData*>
{
public:
    CRawDayData();
    virtual ~CRawDayData();

public:
    tm m_tmDate;

};
Community
  • 1
  • 1
Ragesh Chakkadath
  • 1,521
  • 1
  • 14
  • 32
  • Thanks for the answer, seems to me STL would be best path for conversion. So, how would I do this in STL? What would be the proper syntax for replacing CArray with std::vector in a header file? – user1502835 Jul 05 '12 at 20:00
  • Please go through the documentation. http://www.cplusplus.com/reference/stl/vector/ – Ragesh Chakkadath Jul 06 '12 at 04:05
  • 1
    Btw, the STL containers are not meant to be derived from, they are meant to be used as components (i.e. members) in any class you create, or just use vector as a standalone variable. The problem with deriving from the standard containers is that there is no virtual destructor for std::vector or any of the standard container classes. – Ragesh Chakkadath Jul 06 '12 at 04:23
  • Thanks, this is a big help. However, I'm sttill getting this error with the above code change: RawData.h:55: error: expected template-name before ‘<’ token RawData.h:55: error: expected ‘{’ before ‘<’ token RawData.h:55: error: expected unqualified-id before ‘<’ token – user1502835 Jul 06 '12 at 23:58
  • Check the code here http://codepad.org/yTFInE6g That compiled fine using your class. Perhaps that could help finding what's missing. – Ragesh Chakkadath Jul 07 '12 at 12:00
1

All the MFC stuff are windows only, so they are non-available on Linux. You must convert to using some cross-platform or linux-specific library, such as STL, wxWidgets, etc.

Gang YIN
  • 2,509
  • 2
  • 21
  • 25