gavinpat
asked on
How to integrate old source code in a project?
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__7 998714E_43 DE_11D2_8D 97_0040055 8667B__INC LUDED_)
#define AFX_CHILDFRM_H__7998714E_4 3DE_11D2_8 D97_004005 58667B__IN CLUDED_
#endif // !defined(AFX_CHILDFRM_H__7 998714E_43 DE_11D2_8D 97_0040055 8667B__INC LUDED_)
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?
eg
#if !defined(AFX_CHILDFRM_H__7
#define AFX_CHILDFRM_H__7998714E_4
#endif // !defined(AFX_CHILDFRM_H__7
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?
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?
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.
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.
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."
ASKER
McCreary's answer is the one I wanted I'm afraid I'm forced to reject yours (Answer2000) to accept his.
ok, i didn't guess which part you were having trouble with!
See you round
See you round
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.