CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    C Source file in VC++ workspace

    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.









  2. #2
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: C Source file in VC++ workspace

    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.



  3. #3
    Join Date
    Apr 1999
    Posts
    191

    Re: C Source file in VC++ workspace

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured