My Visual Studio does not load stdafx.h & stdafx.cpp in my project file

Whenever I create project file it won't work because stdafx.h and stdafx.cpp files are not preloaded into the project file, how do I fix this problem


Answer this question

My Visual Studio does not load stdafx.h & stdafx.cpp in my project file

  • BonnieFe

    You can set the use of precompiled headers in your project properties.  You can make it automatic, not happen at all, or happen only on files which have the #incude set ( so only some files use precompiled headers ).


  • Max André Bündchen

    Yeah, I would agree, if for some reason you wanted to extend an existing C++ project into the .NET world, and you couldn't or didn't want to do it via a C# COM object, then you may have reason to use MC++.


  • WalterLeinert

    MC++ is managed C++, C++ with the .NET framework.

    If you want to stick with C++, there's nothing wrong with that.  Certainly you need it for games and AI.  I didn't realise you had prior experience.  in that case, stick to C++, and don't use managed extensions unless you absolutely need to, that is, if you must use the .NET framework for something, or it offers you the best access to something you need, for example, regex ( although boost has regex classes, so maybe not the best example ).


  • capchaos

    Thank you for your input on my problem and your wise thoughts on my future.  I appreciate your time and effort on everything.

                            Fellow Programmer,
                                                        John

  • Florent Montsegur

    debug.pch hasn't been created.

    Precompiled headers in projects consist of two steps: creation through the compilation of a designated cpp file and the /Yc switch, and usage through the compilation of all other cpp files and the /Yu switch.

    I helped someone else on this also.  http://forums.microsoft.com/msdn/ShowPost.aspx PostID=115695
      
    Brian

  • Vai0l0

    Yes you are correct. cout and cin are instances of an unmanged class, and Console is a managed class.  You can tell the diff by finding its definition and seeing if it is declared as class or ref class, the latter being managed.

    Precompiled headers are a feature of the C/C++ compiler that is orthogonal to the /clr switch (for managed code), and it works whether you are including managed vs. unnmanaged class headers.

    As far as I know, all C++ project wizards give you the option of disabling precompiled header support.  Again, that is independent of whether the project is a CLR (managed) project.  An empty project must have precompiled support disabled, since no stdafx.cpp is generated.

    Brian


  • Jim Thompson

    So correct me if I'm wrong, because I am a noob at this sort of stuff, are you guys saying to write C++ code  the old unmanaged way   or should I learn the new way   I"m a student trying to understand the correct things to do.  I remember learning up to Functions and arrays and when I stopped all of a sudden I see, from Deital & Deital, that they're writing the code totally different, hence Console::WriteLIne().  As I started again I felt like the world flipped upside down on me, so forgive me for being a little slow.  One last question before I close this case.  Are companies using the cout<<, cin>>   I'm just trying to keep up with the times.  I"m fairly young, 23, and I have about 2 years left for my CIS degree, so I'm just trying to get into the game with the correct knowledge. 

  • Sirisha

    I did set turn on the precompile header, /yu,  but then when I compile the simplest of code, it gives me an error "debug.pch does not exist."  So what next   I'm using the 2005 beta 2 version.

  • stsong

    cout/cin is part of hte iostream library, which is part of C++.  unmanaged is just a Microsoft marketing term, it means that you manage your own memory.  People have written c and C++ like that for a long time.

    Console is a class in the .NET framework.  Managed code means that it runs in the .NET framework, which means you can access those classes ( which also means you're not using standard C++ anymore, although standard C++ is available to you, the application relies on the .NET framework on the target machine, and as a result, you can use the framework ), and you can mark things to be garbage collected, which means the framework manages memory for you, hence the term 'managed code'.

    Personally, I think if you want to use the .NET framework, you should use C#.  If you want to write code in the most powerful langauge possible, use C++ WITHOUT managed extensions.


  • sparco01

    Yes, I'm saying learn C++.  If you must use MC++, do it after learning C++, and consider C# as an alternative.

    I"m a student trying to understand the correct things to do.

    It depends what you want to do.  Why would you choose MC++  

    Are companies using the cout<<, cin>>  

    I would guarentee that almost every company that uses C++ does not use MC++.  They would use cout/cin if they were doing a console app, for some reason.

    I'm just trying to keep up with the times.

    Not everything that is new, is better, or replaces the old.

    I"m fairly young, 23, and I have about 2 years left for my CIS degree, so I'm just trying to get into the game with the correct knowledge. 

    The correct knowledge is how to program, not how to program 'x'.  What are you learning in your degree Java C# is a lot like Java, and there's plenty of work in it.  C++ will never go away, and it's good to learn, but if you're finding it too complex, C# is probably a good stepping stone.  I'd aim to know C# and C++ if I was looking to get into the job market now, although I admit I speak from the perspective of someone who does know them both, and probably better than any other language.  There's probably plenty of Java work, it just exists outside of my sphere.




  • kondapanaidu

    We hit submit roughly at the same time.  I agree with cgraus C# statement, but there is a third dimension: interoperability with preexisting C++ code with .NET.  That's why you would choose Managed C++ over C#.

  • Dhiraj Gupta27

    Thanks a lot, that conversation you saved helped a lot, does it have to do with managed and unmanaged code   I am doing extensive research on this because When I first started programming I was doing the old cout<<, cin>> type of code, is this what you call unmanaged code   I found that when I choose CLR Console "Empty" template that it actually works with the Console::WriteLine().  is this what you call Managed code

  • kaffeeschluerfer

    I am guessing MC++ is the .Net framework.  But I have previous C++ 6.0 experience, and just several months ago worked on, for school,  3/4 of the Deital & Deital "How to program in C#."  C# was sort of easier but it just didn't click with me, I can't explain it, but with C++ I could feel it.  LOL, I know that sounds funny.  I want to stick with C++ because it's the first langurage I really got into, I hated VB, and because from the research I have done, C++ is very versitile ( Correct me if I am wrong ).  I am going to devry, and my major is in game design; however, I would, in the future, like to work up to AI programming.

  • BeckKhiem

    My pleasure - I hope it all works out for you.


  • My Visual Studio does not load stdafx.h & stdafx.cpp in my project file