I really have no clue what this header file does, can someone please explain? Also where do you get it?
I really have no clue what this header file does, can someone please explain? Also where do you get it?
It's needed in MSVC++. Not really a standard header file.
stdafx.h is also used in the open GL tutorial for SetTextColor and TextOutA.
Where do I find those functions in standard C? (I'm using mingw on dev cpp)
>>Where do I find those functions in standard C?
You don't because they're not standard functions.
stdafx header file contains prewritten code to set up the console window you use when writing code with MSVC. This allows you to enlarge the console window, scroll the console window, etc., all of which isn't possible in formats such as Dev-C++, Borland, etc., without you adding the necessary code from the underlying Windows API.
Originally posted by Casey
>>Where do I find those functions in standard C?
You don't because they're not standard functions.
So how do you output anything to a window at all in standard C++ then ? Only through windows controls ?
edit: ok, thanks elad. Guess this tutorial isn't for me than
Last edited by darksaidin; 07-21-2003 at 07:36 AM.
Hold on. Don't run away or throw away the tutorial. It's just that things aren't as simple as they could be. You can write all the standard C++ code you want using MSVC. It will compile fine with other MSVC compilers and if the other programmer isn't using MSVC they just comment out the stdafx header file. In fact, once you list the stadafx file in the list of includes you can almost forget you are using MSVC and pretend you are using a "pure" C++ compiler. Problem is there is no "pure" C++ compiler. They all have their quirks. You learn to work around them. And yes, there can be problems with portability, so sticking with a given compiler and using it without consideration of porting it or sticking to standard C++ as much as possible is the key.
If you don't know already, there is a difference in how you write code to output material on the screen using console/DOS vs using Windows. In console/DOS mode you use cout (for C++) or printf() (for C) (in reality you can use printf() in C++ too, but you can't use cout in C). In Windows you have to use Text output functions that are event driven, even though the Windows API is written in C/C++. stdafx contains the magic that allows you to use cout or printf() to display output on the screen without having to use the Text output functions or other output functions in the Windows API itself. For now, don't worry about what's in the "magic box". Just use it. You can draw back the curtain to see the wizard later in your career.
Point is I'm new to C. I used to code with Delphi but I was pretty much tired of header translation (whenever something new is released, headers are for C and not for OP/Delphi). That was the only reason to switch to C in the first place. Now that I come to find the same problem here, I could as well go back to Delphi. At least there it's not the Delphi code that is not running but "only" some Headers I got to translate
Anyway, I just skipped that part of the tutorial. Now I got a different problem, but maybe I'll find the sollution somewhere here on the board (search button, fear me! )...
You can turn off stdafx.h if you want. stdafx.h doesn't actually contain anything more than #includes of other headers. The idea is that you put very widely used headers that won't change in stdafx.h, and they are precompiled.
All it does is make builds faster. It's not even needed in VC++ if you turn precompiled headers off.