Results 1 to 5 of 5
  1. #1
    Dolebat's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    10
    Reputation
    10
    Thanks
    1
    My Mood
    Mellow

    Question #include "stdafx.h"?

    Hello all!

    I am learning C++ and using MS Visual Studio 2010 as my IDE. I am following the tutorials at LearnCPP.com and on the first tutorial I hit a snag. In the tutorial 0.6 it clearly states: Important note to Visual Studio users:

    Visual studio programs should ALWAYS begin with the following line:

    #include "stdafx.h"

    When I do that on the Hello World program I get the following error:
    Code:


    Code:
    1>Build started 3/29/2011 2:18:18 PM.
    1>InitializeBuildStatus:
    1>  Touching "Debug\HelloWorld.unsuccessfulbuild".
    1>ClCompile:
    1>  Helloworld.cpp
    1>c:\users\jon\documents\visual studio 2010\projects\helloworld\helloworld\helloworld.cpp(2): fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
    1>
    1>Build FAILED.
    1>
    1>Time Elapsed 00:00:00.25
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    If I build or Run [Without Debugging], leaving out #include "stdafx.h" it works fine. I know since I got it working, It shouldn't matter, but its bugging me and I have a feeling it might trip me up later if I don't know.

    Thanks in advance!
    Dolebat

  2. #2
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    The person who wrote that tutorial is a gigantic homo****** then. You only include stdafx.h when you let microsoft create the console32 app for you.

    When creating a project check the "Empty Project" checkbox(don't know what it says exactly), then you won't need stdafx.h
    Ah we-a blaze the fyah, make it bun dem!

  3. The Following 2 Users Say Thank You to Hell_Demon For This Useful Post:

    Dolebat (03-30-2011),why06 (03-30-2011)

  4. #3
    Dolebat's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    10
    Reputation
    10
    Thanks
    1
    My Mood
    Mellow
    Gotcha, thanks a bunch!

  5. #4
    Melodia's Avatar
    Join Date
    Dec 2009
    Gender
    female
    Posts
    2,608
    Reputation
    276
    Thanks
    1,662
    My Mood
    Dead
    Lolol telling people to use precompiled headers without explaining them and with Hello World ?
    Love You All~

  6. The Following User Says Thank You to Melodia For This Useful Post:

    Hell_Demon (03-30-2011)

  7. #5
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,159
    Reputation
    490
    Thanks
    2,253
    Tick empty project next time