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

This is a discussion on stdafx.h: no such file or directory - what to do? within the C++ Programming forums, part of the General Programming Boards category; hi everybody i'm brand new in this area - i have read the C++ tutorial and began with the OpenGL ...

  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
    21,310
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    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,189
    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.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    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,167
    GCC (which Code::Block uses) certainly does support precompiled headers, but transparently, using .gch files.
    Last edited by cyberfish; 12-24-2009 at 05: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, 01: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, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21