LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 06-24-2004, 11:31 PM   #1
sheenak
LQ Newbie
 
Registered: Apr 2004
Posts: 23

Rep: Reputation: 15
Porting from VC++: MFC Support on Linux


Hi Guys,

I am working on Porting from VC++ (version 6) to Kdevelop in Linux.

The source code has several of the inbuilt constructs of MFC.

eg:

Some of the classes are declared of type - CList, CObject.

Just a small information about the CObject class:

Quote:
CObject is the principal base class for the Microsoft Foundation Class Library. It serves as the root not only for library classes such as CFile and CObList, but also for the classes that you write. CObject provides basic services, including

Serialization support
Run-time class information
Object diagnostic output
Compatibility with collection classes

Note that CObject does not support multiple inheritance. Your derived classes can have only one CObject base class, and that CObject must be leftmost in the hierarchy. It is permissible, however, to have structures and non-CObject-derived classes in right-hand multiple-inheritance branches.
Clist class inherits from CObject Class.

How can the usage of such classes be replaced in the source Code.

Eg: Clist* abc;

What should be done to make this statement working in Linux.


Can any one suggest me on this issue.


Cheers
a_mlt1
 
Old 06-25-2004, 11:03 AM   #2
dakensta
Member
 
Registered: Jun 2003
Location: SEUK
Distribution: Debian & OS X
Posts: 194

Rep: Reputation: 35
I think this depends on the usage of CList and how much of the underlying CObject functionality is actually used and how.

3 thoughts spring to mind:

Wrap a standard list in a CList class of your own definition so that the function calls simply defer those to std::list (assuming you only use the list functionality). You might have to do something similar with POSITION (-> iterator). Maybe duplicate the functionality of any CObject calls made (like serialize?)

Alternatively, you could look at wine and winelib, which I think provides a limited MFC interface on Linux.

Or just get rid of the CLists completely and rewrite the code using something else.
 
Old 01-13-2005, 05:14 AM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,989

Rep: Reputation: 63
Re: Porting from VC++: MFC Support on Linux

The simplest way to replace CObject is to use the standard template library.

Something like this will give you something with almost identical functionality (as well as being efficient, exception-safe and so on):
Code:
#include <list>

typedef CList std::list<void *>;
(if memory serves, this is roughly how CList is implemented internally.)

You can also improve your code by using std::list<type> to create a list of items of type type; the compiler will check that you never inadvertently try to add an object of the wrong type.


If you're using Qt or the KDE libraries, then CObject just becomes QObject. Otherwise, you can just use an empty base class (unless you need specific methods of CObject, which then you'll have to write yourself):
Code:
class CObject{};
This has the advantage that some compilers can optimize away the CObject class so that it takes up no memory in base classes, although pointers to CObjects will still be virtual. You'll still have to explicitly derrive classes from CObject, however.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Win32/MFC porting toolkit? Artik Programming 3 08-09-2005 01:03 PM
HP-UX to linux porting arunprakash Other *NIX 2 03-01-2005 10:53 PM
Compiling/Converting MFC to Linux PhaseSpace Linux - Software 4 02-02-2005 01:02 PM
Porting C++ from HP-UX 11.0 to Linux paul sachs Other *NIX 2 01-10-2005 05:37 PM
Does my Brother MFC-5100c work under linux? mikeylikesit! Linux - Hardware 2 10-08-2002 10:06 AM


All times are GMT -5. The time now is 06:48 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration