Results 1 to 9 of 9

Thread: stdafx.cpp

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    134

    stdafx.cpp

    When I make a new non-blank program this file is in the project but it only has one include which has a bit of code I can't even begin to understand...

    So my question is: What is StdAfx meant for?

  2. #2
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771
    Stdafx is used for precompiled headers by MS Visual C++. If you include some headers in stdafx.h, and you include stdafx.h in every cpp file, then stdafx only has to be compiled once, which will speed up compile time.

    You don't need stdafx.h/.cpp, you can delete both files. If you do that you must also turn precompiled headers off (project, settings, C++, cotegory: precompiled headers, not using precompiled headers)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    134
    Oh, thanks, I guess I'll leave it.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Just remember that if you don't turn it off stdafx.h must be the FIRST include in EVERY one of your .cpp files, else the file won't compile.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    134
    it MUST be in EVERY single one?

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yep. Every .cpp or .c file that is. Not in every .h file.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Unless you turn off precompiled headers, in which case you don't need it.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    ...if you don't turn it off stdafx.h must be the...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Missed that But repeating it is still valid if you think about the responses...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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