Thread: Problem building a Release

  1. #16
    Registered User
    Join Date
    Jun 2006
    Posts
    23
    Thank you. That's what I figured. I wonder why The Shark had it there in the first place - unless the code was from something else (that did need stdafx.h) and he modified it to create an increasing sequence of numbers as a demo for this board.

    As I said, the default on my VC++EE is not to use precompiled headers.

  2. #17
    C++ SharK The SharK's Avatar
    Join Date
    Mar 2004
    Location
    Denmark
    Posts
    62

    Thumbs up

    Hi CondorMan

    I have Visual C++ Express Edition and can't compile this code. It says that stdafx.h does not exist. If I comment out that line, it says that it can't find windows.h.
    I have (now - had) quite the same annoying thing,
    but I could compile the code though.

    But now you mentioned it here, I too now have chosen:
    "Not Using Precompiled Headers"

    But we'll have to remember as Mario F. said:
    On those next projects you come to create, make sure you uncheck the tick box "use precompiled headers" on the project creation screen.
    Thanks for bringing up the subject
    Studying programming languages,
    you'll ALWAYS be a student ;-)

  3. #18
    Registered User
    Join Date
    Jun 2006
    Posts
    23
    An easier way is not to use stdafx.h as it doesn't seem to be needed for your code. As I said, even when I set "Not Using Precompiled Headers" but left the reference to stdafx.h, it still generated the error!

  4. #19
    C++ SharK The SharK's Avatar
    Join Date
    Mar 2004
    Location
    Denmark
    Posts
    62
    Hi ConderMan


    Yes, I see the code doesn't need it obviously.
    When I set "Not Using Precompiled Headers" and leave the reference to stdafx.h it compile fine.

    But the opposite, if I set it to "use Precompiled Headers", and remove the reference to stdafx.h, I get an error !



    regards,


    The SharK
    Studying programming languages,
    you'll ALWAYS be a student ;-)

  5. #20
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    If you look inside the stdafx.h file, you will see why the compiler doesn't bother you with any errors.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #21
    C++ SharK The SharK's Avatar
    Join Date
    Mar 2004
    Location
    Denmark
    Posts
    62
    Hi Mario F.

    If you look inside the stdafx.h file, you will see why the compiler doesn't bother you with any errors.
    hmm... what exactly is it I should be seeing/noticeing

    My stdafx.h Header file looks like this:
    Code:
    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    //
    
    #pragma once
    
    
    #define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
    #include <stdio.h>
    #include <tchar.h>
    
    
    
    // TODO: reference additional headers your program requires here
    Studying programming languages,
    you'll ALWAYS be a student ;-)

  7. #22
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Well, let's take a look at it...

    #pragma once is a C++ 2005 compiler instruction that replaces the #ifndef and #define pair as header guards. So basically this is simply an header guard to ensure the header is only included once.

    #define WIN32_LEAN_AND_MEAN instructs the compiler to use shorter versions of certain win32 header files, making the code smaller in return.

    So far, none of these directives are capable of producing errors. They are simple instructions to the compiler. Next comes the includes...

    Code:
    #include <stdio.h>
    #include <tchar.h>
    There isn't even the need to analyze these one by one. Suffice to say that all standard and C++ 2005 header files have header guards included. So, even if you used these same headers in your project, they wouldn't be included twice.

    This is why including the stdafx header when "don't use precompiled headers" is turned on, doesn't produce errors. This header file is pretty much innocuous.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Results in Debug and Release mode are different
    By jaro in forum C Programming
    Replies: 11
    Last Post: 05-27-2006, 11:08 AM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  3. Mesh Release() Problem
    By Morgul in forum Game Programming
    Replies: 6
    Last Post: 03-07-2006, 02:50 PM
  4. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM