1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Resolved Microsoft Visual C++ Express header files

Discussion in 'Other PC Software' started by hllstrHUNTER, 2009/10/22.

  1. 2009/10/22
    hllstrHUNTER

    hllstrHUNTER Inactive Thread Starter

    Joined:
    2005/12/17
    Messages:
    107
    Likes Received:
    0
    Hello,

    I am using Microsoft Visual C++ to create Win32 Console applications and am having trouble using the stdafx.h header file. I get the following error message when compiling:

    fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory


    This is normally not an issue for me as I generally just use the stdio.h header; However, there are times when I have to run programs written by other people that like to use the precompiled header that comes with the program, which makes the problem even stranger because we are using the same development tool. I usually just change the stdafx to stdio and compile it, but I am now to the point where I wish to fix the problem. I have tried Google to find the header file I need to add but can't locate it. Even if I did find it I am not sure that I can just add it to the library.:confused:

    Does anyone here know enough about this to help me out? I would greatly appreciate it. :)
     
  2. 2009/10/23
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    15,174
    Likes Received:
    412
    Arie,
    #2

  3. to hide this advert.

  4. 2009/10/23
    hllstrHUNTER

    hllstrHUNTER Inactive Thread Starter

    Joined:
    2005/12/17
    Messages:
    107
    Likes Received:
    0
    Thanks Arie. :cool:

    I'll post back if I find the solution.
     
  5. 2009/10/29
    hllstrHUNTER

    hllstrHUNTER Inactive Thread Starter

    Joined:
    2005/12/17
    Messages:
    107
    Likes Received:
    0
    Ok I think I may have it figured out. I created a new project using the Microsoft precompiled header, stdafx.h. Then, clicked on the header file just to see what was in it; and, lo and behold.....there was my answer.


    Contents of basic precompiled header in VC++ 2008:

    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    //

    #pragma once

    #include "targetver.h "

    #include <stdio.h>
    #include <tchar.h>



    // TODO: reference additional headers your program requires here

    -----------------------------------------------------------------------
    I read up a little on Precompiled headers and found them to be, basically, just a time saver when debugging. Instead of placing all of the #include files in the .cpp file(which causes the compiler to have to debug each one, every time the programmer wants to debug his actual code), the precompiled header gives the programmer a place to include all of the needed header files in one convenient location(in the header file folder, .h extension), allowing the compiler to skip these once they have been debugged for the first time.


    So when you have a program that looks like this:


    /* example*/

    #include <stdafx.h>

    int main (void)
    {
    ......
    return 0;
    } //main

    The stdafx,which stands for standard application frameworks, includes one or more header files itself, depending on what the author decided to place there.
     
  6. 2009/10/29
    hllstrHUNTER

    hllstrHUNTER Inactive Thread Starter

    Joined:
    2005/12/17
    Messages:
    107
    Likes Received:
    0
    So the reason I couldn't just run someone else's code using the stdafx.h header, is because the stdafx.h header does not exist in the standard library, It is created using other header files which are. To run a code using a precompiled header, one would either have to have the precompiled header that the author used or recreate one.
     
  7. 2009/10/29
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    15,174
    Likes Received:
    412
    Thanks for posting your solution.
     
    Arie,
    #6

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.