stdafx.h

stdafx.h: When do I need it?

99封情书 提交于 2019-11-30 10:50:01
I see so much code including stdafx.h. Say, I do not want pre-compiled headers. And I will include all the required system headers myself manually. In that case is there any other good reason I should be aware of where I require stdafx.h ? If you don't want to use precompiled headers, then there is no point to using a standard include file - this will slow down the build for every file that includes it and cause them to include extra stuff that they do not need. Get rid of it and just include the headers they need. Even without pre-compiled headers stdafx.h could be handy as it groups header

Handling stdafx.h in cross-platform code

做~自己de王妃 提交于 2019-11-29 19:40:17
I have a Visual Studio C++ based program that uses pre-compiled headers ( stdafx.h ). Now we are porting the application to Linux using gcc 4.x. The question is how to handle pre-compiled header in both environments. I've googled but can not come to a conclusion. Obviously I want leave stdafx.h in Visual Studio since the code base is pretty big and pre-compiled headers boost compilation time. But the question is what to do in Linux. This is what I found: Leave the stdafx.h as is. gcc compiles code considerable faster than VC++ (or it is just my Linux machine is stronger ... :) ), so I maybe

stdafx.h: When do I need it?

爷,独闯天下 提交于 2019-11-29 15:59:50
问题 I see so much code including stdafx.h. Say, I do not want pre-compiled headers. And I will include all the required system headers myself manually. In that case is there any other good reason I should be aware of where I require stdafx.h ? 回答1: If you don't want to use precompiled headers, then there is no point to using a standard include file - this will slow down the build for every file that includes it and cause them to include extra stuff that they do not need. Get rid of it and just

How to use stdafx.h properly?

三世轮回 提交于 2019-11-29 11:54:30
问题 What is the proper way to use stdafx.h , in terms of separating dependencies? If I put everything in there, then my compiles are blazing fast, and all I need to say in any file is #include "stdafx.h" with the caveats that: I no longer know which files depend on which headers. It reduces modularity, making my code less reusable. I can no longer separate C #include s from C++ ones (e.g. cstring versus string.h ) without a great deal of pain. (Speaking of which, does this even matter?) If I put

include stdafx.h in header or source file?

a 夏天 提交于 2019-11-28 11:59:44
I have a header file called stdafx.h and this one is precompiled of course. I've read that I should include these files into my .cpp files, but some of these statements are already needed in the header file coming with that. Should I add the stdafx into my header or into my cpp? I thought it was good practise to put it into the header, but I seem to be obliged to put it into the header instead. Example: stdafx contains freeglut. my class header file has an attribute of GLenum. Should I include the stdafx into the .h of the class? stdafx.h should be the first include in EVERY cpp file in your

afxwin.h issues in Visual Studio 2015 Windows Form App

醉酒当歌 提交于 2019-11-28 07:05:36
问题 A while ago i wrote a C++ CLI Windows Form app, which compiled fine in Visual Studio 2013. Now i wanted to recompile it in Visual Studio 2015 Update 1 but i'm facing a problem, and after hours of tests i figured out the culprit is afxwin.h . TL;DR - Is there any way i can use stdafx.h (so afxwin.h and all other imports coming with it) in a Windows Form app compiled with Visual Studio 2015 without having the app crash upon start? Here's how to reproduce the same issues i'm facing in my app.

Is there a way to use pre-compiled headers in VC++ without requiring stdafx.h?

喜欢而已 提交于 2019-11-27 20:48:47
I've got a bunch of legacy code that I need to write unit tests for. It uses pre-compiled headers everywhere so almost all .cpp files have a dependecy on stdafx.h which is making it difficult to break dependencies in order to write tests. My first instinct is to remove all these stdafx.h files which, for the most part, contain #include directives and place those #includes directly in the source files as needed. This would make it necessary to turn off pre-compiled headers since they are dependent on having a file like stdafx.h to determine where the pre-compiled headers stop. Is there a way to

Error C1083: Cannot open include file: 'stdafx.h'

允我心安 提交于 2019-11-27 06:44:16
问题 When I compiled this program (from C++ Programming Language 4th edition): main.cpp #include <stdafx.h> #include <iostream> #include <cmath> #include "vector.h" using namespace std; double sqrt_sum(vector&); int _tmain(int argc, _TCHAR* argv[]) { vector v(6); sqrt_sum(v); return 0; } double sqrt_sum(vector& v) { double sum = 0; for (int i = 0; i != v.size(); ++i) sum += sqrt(v[i]); return sum; } vector.cpp #include <stdafx.h> #include "vector.h" vector::vector(int s) :elem{ new double[s] }, sz

include stdafx.h in header or source file?

橙三吉。 提交于 2019-11-27 06:39:56
问题 I have a header file called stdafx.h and this one is precompiled of course. I've read that I should include these files into my .cpp files, but some of these statements are already needed in the header file coming with that. Should I add the stdafx into my header or into my cpp? I thought it was good practise to put it into the header, but I seem to be obliged to put it into the header instead. Example: stdafx contains freeglut. my class header file has an attribute of GLenum. Should I

Is there a way to use pre-compiled headers in VC++ without requiring stdafx.h?

跟風遠走 提交于 2019-11-26 22:58:51
问题 I've got a bunch of legacy code that I need to write unit tests for. It uses pre-compiled headers everywhere so almost all .cpp files have a dependecy on stdafx.h which is making it difficult to break dependencies in order to write tests. My first instinct is to remove all these stdafx.h files which, for the most part, contain #include directives and place those #includes directly in the source files as needed. This would make it necessary to turn off pre-compiled headers since they are