Click to See Complete Forum and Search --> : C Source file in VC++ workspace


April 6th, 1999, 04:14 PM
Hi,

Environment: VC++5.0, Windows NT.

I have a question related to Precompiled header.

I have a dialog based application.When I am trying to add a C source file
i.e test.c and try to build the work space its giving an error "Unexpected end of file while looking for a precompiled header directive".

Any body knows the answer for this, Please let me know.

Thanx in advance.

Gomez Addams
April 6th, 1999, 04:27 PM
The compiler is expecting a pre-compiled header include directive.
This is probably because the argument /Yu is given. To correct
this add an include statement like #include "stdafx.h" to the c file.
You will then get an error like pre-compiled header not generated
with this compiler. To correct this either rename the file to .cpp or
change the project settings for this file to use the c++ compiler.

Bore
April 6th, 1999, 05:10 PM
I can see that Gomez answered your question, but having just gone through this problem I can give you more details. But I have VC6, so I don't know how this will map back to VC5. Anyway, here's what I did:

1) Add the C file to the project.
2) Right click on the C file in the file view, then change the C/C++ settings to "not using precompiled headers."
3) If you need to call your C module from your C++ module, then #include your C module's prototype file like this:

extern "C"
{
#include "mymodule.h"
}

Mine works fine after that.