|
-
April 1st, 1999, 01:31 PM
#1
Adding existing C file to C++/MFC project
Anyone ever try to add an existing C file to an existing C++/MFC project? When I do it, I get
fatal error C1010: unexpected end of file while looking for precompiled header directive
Ok, so I #include "stdafx.h" at the top. But then I get:
fatal error C1853: 'Debug/GTest.pch' is not a precompiled header file created with this compiler
Anyone have any ideas?
-
April 1st, 1999, 01:48 PM
#2
Re: Adding existing C file to C++/MFC project
Hi! Goto to project settings-C++-precompiler header && disable it
-
April 1st, 1999, 01:50 PM
#3
Re: Adding existing C file to C++/MFC project
to cpp or c after stdafx.h I added
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
=-----------
to h file
#if !defined(AFX_utils_h)
#define AFX_utils_h
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
and I called my c file, .cpp. Everything works fine. If you want to use .c extension and compile, I guess you need to use Extern "c" Precompiler directive.
-
April 1st, 1999, 06:00 PM
#4
Re: Adding existing C file to C++/MFC project
I encountered this problem recently. It was caused by building a pch file through stdafx.cpp and then including stdafx.h
in a c file. This is why the message mentions "not a precompiled header file created with this compiler". In my case,
I changed the .c file to a .cpp and it worked fine. If you don't want to do this, I think there is an option to use the C++
compiler on C files and that should fix things. Good Luck.
Gomez
-
April 2nd, 1999, 02:48 AM
#5
Re: Adding existing C file to C++/MFC project
for the header file, add this:
extern "C"
{
#include "the_c_header.h"
}
and before each function add
extern "C"
so if the old C funcion was:
void myFunct(void)
{
}
change it to:
extern "C" void myFunc(void
{
}
Rail
Recording Engineer/Software Developer
Rail Jon Rogut Software
[email protected]
http://home.earthlink.net/~railro/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|