Thread: stdafx.h: no such file or directory - what to do?

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    2

    stdafx.h: no such file or directory - what to do?

    hi everybody

    i'm brand new in this area - i have read the C++ tutorial and began with the OpenGL tuts.

    i have made it as far as "A First Windows Application" (A First Windows Application - Cprogramming.com), where i copied the code example into Code::Blocks to see how it works - but i doesn't :S

    i get the error: "stdafx.h: No such file or directory"

    i've searched my entire pc for that file, but it doesnt seems to exist - what should i do?

    thanks in advance from the all green cpp-programmer

    merry christmas

    //splazz

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Just remove the line of code that involves "stdafx.h". You can about what it means later as it is not important to you right now.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Using Visual Studio by any chance? If so, then you might want to look into precompiled headers. Either use it or disable it.
    http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    It's better to disable precompiled headers, they are more pain than its worth. On a modern computer, they really don't save you any compile time unless you are including thousands of headers in a million lines of code application.

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    2
    thanks for the quick replies

    but doesnt it include functions that i need? if it doesnt, then i dont understand why it's included :s

    as i said in my starting post, i'm using Code::Blocks - how do i disable precompiled headers?

    //splazz

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by abachler View Post
    It's better to disable precompiled headers, they are more pain than its worth. On a modern computer, they really don't save you any compile time unless you are including thousands of headers in a million lines of code application.
    An individual opinion rather than a fact.
    Just include windows.h. Time it with and without precompiled headers. Big difference.
    They are not a lot of pain, really. Just stick #include "stdafx.h" into every source file and it will compile. Big pain? I think not.

    As for the original question, if you see any #include "stdafx.h" in the code you copy, remove the line. Hopefully, this should fix it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Quote Originally Posted by splazz View Post
    thanks for the quick replies

    but doesnt it include functions that i need? if it doesnt, then i dont understand why it's included :s

    as i said in my starting post, i'm using Code::Blocks - how do i disable precompiled headers?

    //splazz
    precompiled headers is a visual studios thing that codeblocks does not do (to my knowledge). Like everyone has said, remove the stdafx.h line and include the appropriately needed headers.

  8. #8
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    GCC (which Code::Block uses) certainly does support precompiled headers, but transparently, using .gch files.
    Last edited by cyberfish; 12-24-2009 at 06:20 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM