#### Archived

This topic is now archived and is closed to further replies.

# stdafx.h - why this mess????? typedef error

This topic is 5230 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi. QUESTION 1. - stdafx.h problem I created a simple console win32 application and there were 3 files generated. 1 containing main ie. #include "stdafx.h" <--- whats this MS mess?? int _tmain(int argc, _TCHAR* argv[]){ return 0;} and 2 files. stdafx.h and stdafx.cpp. Fine. the MS wizard fortunately managed to create a piece of code that actually compiles. ok. Now I am trying to add a simple class eg. CFoo stored in 2 separate classes. Foo.h and Foo.cpp. Obviously it doesnt work. when I include this class in main.cpp. I've put all the #include's the normally I would put in main.cpp into stdafx.h. Now it compiles. Does it mean that stdafx.h is kind of file where I should put all my #include's rather than into main.cpp I also read about those problems affected by this here: http://support.microsoft.com/default.aspx?scid=kb;EN-US;815644 but unfortunately its not enough for me to understand it. Can you please exaplin the purpose of stdafx.h & .cpp. QUESTION 2. - typedef problem I've managed to add those extra two files Foo.h & .cpp and now in my Foo.h where I declared my class Foo I need to use typedef. so the implementation looks like this:
#ifndef  _FOO_H_    // where are in Foo.h file

#define	 _FOO_H_
#include <vector>

typedef int u32; // <<<------- THIS WORKS

typedef vector<char*> TestNames;   // <--- THIS DOESNT WORK!! WHY??

namespace MY
{
class CFoo
{
public:
CFoo(){}
private:
u32 numNames;
TestNames names;
};
};

#endif

Why hte second typedef doesnt work? I read somwhere before that they should be defined in .cpp file but why? I want to use it in .h so I can declare variables in my class. [edited by - papa on May 31, 2004 5:31:48 AM]

##### Share on other sites
http://www.catb.org/~esr/faqs/smart-questions.html

1. This "MS mess" is something called precompiled headers, and is there to decrease compile time. It''s perfectly described in MSDN.

2. There''s no vector in the global namespace. The <vector> file defines std::vector.

##### Share on other sites
What''s wrong with "Method 1" and

static TestNames names;

?

##### Share on other sites
You deleted your second message . Now nobody understands what "Method 1" means.

##### Share on other sites
http://gamedev.net/community/forums/forum.asp?forum_id=31 is a more appropriate forum for these kind of questions.

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 25
• 9
• 57
• ### Forum Statistics

• Total Topics
632642
• Total Posts
3007620
• ### Who's Online (See full list)

There are no registered users currently online

×