Solved

How to integrate old source code in a project?

Posted on 1998-11-27
6
224 Views
Last Modified: 2010-04-01
I know this is a basic question but how do you integrate old (non MFC) source code into Visual C++ projects, I want to add header files for classes from another compiler, these files don't contain any of the MFC sentries and file footer junk:

eg
#if !defined(AFX_CHILDFRM_H__7998714E_43DE_11D2_8D97_00400558667B__INCLUDED_)
#define AFX_CHILDFRM_H__7998714E_43DE_11D2_8D97_00400558667B__INCLUDED_

#endif // !defined(AFX_CHILDFRM_H__7998714E_43DE_11D2_8D97_00400558667B__INCLUDED_)

If the files are just added to the project as they are then when this is done Microsoft gives an error. How can I add these files to my project so that the classes are recognized?
0
Comment
Question by:gavinpat
6 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 1178740
Well, i never experienced big problems when integrating 'foreign' code to MFC projects (yep, of course, there were smaller ones ;-) What error does the compiler give?
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1178741
Project/Add To Project/Files...

I do this all the time.  As I prefer to write my headers by hand.

The crap at the bottom and top of the file, is to prevent the same .h being included more than once...basically the 1st time thru, the symbol AFX_whatever won't be defined, therefore the #if stuff will get included, and the symbol will be defined...the 2nd time, the symbol is already defined, so most of the header is not processed.

The reason for all those hex numbers is just to make a unique symbol name.  There is no magic there.
0
 

Expert Comment

by:McCreary
ID: 1178742
Chances are your code implementation does not #include <stdafx.h> and the compiler will complain about missing the pre-compiled reader.  I am assuming that you are using Visual C++ compiler in IDE.  Go to Project/Setitings menu.  On Project Settings dialog use Tab C/C++.  Highlite the offending .CPP file.  In the Category list box find "Precompiled Headers"  Now set the radio button "Not using precompiled headrs."
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:gavinpat
ID: 1178743
McCreary's answer is the one I wanted I'm afraid I'm forced to reject yours (Answer2000) to accept his.
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1178744
ok, i didn't guess which part you were having trouble with!

See you round
0
 

Accepted Solution

by:
McCreary earned 70 total points
ID: 1178745
Chances are your code implementation does not #include <stdafx.h> and the compiler will complain about missing the pre-compiled reader.  I am assuming that you are using Visual C++ compiler in IDE.  Go to Project/Setitings menu.  On Project Settings dialog use Tab C/C++.  Highlite the offending .CPP file.  In the Category list box find "Precompiled Headers"  Now set the radio button "Not using precompiled headrs."
I should have made this an answer instead of a comment.  Do I get the 75 points?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

2 Experts available now in Live!

Get 1:1 Help Now