Click to See Complete Forum and Search --> : Adding existing C file to C++/MFC project
Bore
April 1st, 1999, 12:31 PM
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?
Dmitriy
April 1st, 1999, 12:48 PM
Hi! Goto to project settings-C++-precompiler header && disable it
Santhosh Cheeran
April 1st, 1999, 12:50 PM
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, 05:00 PM
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
Rail Jon Rogut
April 2nd, 1999, 01:48 AM
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
railro@earthlink.net
http://home.earthlink.net/~railro/
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.