Questions tagged [stdafx.h]

stdafx.h is a file, generated by Microsoft Visual Studio IDE wizards, that describes both standard system and project specific include files that are used frequently but hardly ever change.

Visual C++ will precompile this file to reduce overall compile times.

The AFX in stdafx.h stands for Application Framework eXtensions. AFX was the original abbreviation for the Microsoft Foundation Classes (MFC).

76 questions
5
votes
1 answer

Best way to include stdafx.h, when it is 1 directory up?

Imagine the following source files: src/StdAfx.h src/moresrc/MyFile.cpp In MyFile.cpp, I need to include the precompiled header file StdAfx.h. If I do this: #include "../StdAfx.h" then I will get the compiler error: warning C4627: '#include…
dan-O
  • 354
  • 1
  • 10
5
votes
1 answer

Question about precompiled headers in Visual C++

If I put a header (a.h) into stdafx.h and that header includes another header (b.h) that is not mentioned in stdafx.h, will b.h be visited every time someone includes a.h or is it compiled in as part of a.h? If it is compiled into a.h, what happens…
Dave
  • 885
  • 2
  • 10
  • 20
4
votes
1 answer

fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?

I'm getting the following error while compiling my project: fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source? But if I add #include "StdAfx.h" as it…
Ting Sun
  • 173
  • 1
  • 1
  • 10
3
votes
3 answers

About stdafx.h missing in my compiler(mingw32 on windows)

I just have a quick question. I've noticed that I don't have stdafx.h in my compiler(mingw32 on windows) Am I supposed to have it? Or maybe is there a way to get around it? Thanks for reading EDIT: ok here is my current build log once I took out ALL…
Molmasepic
  • 1,015
  • 2
  • 13
  • 18
3
votes
4 answers

Error C1083 Cannot open include file: 'stdafx.h': No such file or directory

I am new to visual studio.I have created a simple console application and then selected an empty project of c++.Then pasted the following code #include "stdafx.h" #include #include #include #include…
nadun
  • 393
  • 1
  • 4
  • 14
3
votes
1 answer

Why do i have to #include "stdafx.h" in Microsoft visual studio c++ applications?

If i use a normal text editor or Code::Blocks this problem didn't occur. but in visual studio , I have to include stdafx.h header file in order to compile the program without errors. I want to know whats the use of this header file and why its in…
user5543585
3
votes
1 answer

Precompiled Header and MSBuild

I have a precompiled header that needs to be included atop each .cpp in my project. I fear that I will waste a lot of time explaining and fixing that in coworkers code. Is there an MSBuild step that I can do to #include "stdafx.h" at the top of all…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
3
votes
2 answers

c++ fatal error c1083 project was fine before, what now?

I have a (com) c++ project, which uses a (.net) c++ dll. The project was compiling and running ok. Now, all I did was make changes to the dll, and I'm getting a fatal error c1083- cannot open include file stdafx.h - when recompiling my (com)…
user228058
  • 465
  • 1
  • 7
  • 22
3
votes
1 answer

error: 'CAtlServiceModuleT' : is not a member of 'ATL'

Building correctly a C++/ATL project : I'm trying to use my MFC code into an ATL (Service EXE) project. In which, I've included all my Existing Items. When I've configured the project to Use MFC in a Shared DLL, I've had this error message while…
Lucie kulza
  • 1,357
  • 6
  • 20
  • 31
3
votes
1 answer

Sytem-wide Hotkey Shortcut(Windows/Qt) : Prevent window lock?

I am trying to figure a way I can use a system wide hot-key in my Qt application. To check for messages with GetMessage you need a while() loop. This is causing the window to lock up and become disabled, however functions still get processed for…
3
votes
0 answers

MFC in Visual Studio 2012 - afx.h file not found

I created an new static library project in VS 2012, with option MFC selected. It created few files in the project, stdafx.h, targetver.h, stdafx.cpp. However in stdafx.h there are includes for afx.h, afxwin.h etc and they were marked as errors. I…
harimothu
  • 41
  • 5
3
votes
4 answers

Writing C++ in Xcode 4

I'm trying to learn C++ and I'm not a fan of Windows, therefore using Visual Studio isn't ideal. I have Xcode on my Mac though. I wrote a program in C++ in Visual Studio and it works fine. When I transfer the code to Xcode (using the c++ tool…
binary101
  • 1,013
  • 3
  • 23
  • 34
2
votes
2 answers

Can't access function from header file

//head.h// extern int sum(int,int); //head.cpp// #include "head.h" #include "stdafx.h" int sum(int x, int y) { return (x+y); } //mainfn.cpp// #include "head.h" #include "stdafx.h" #include string #include iostream #include stdio.h using…
DTdev
  • 538
  • 1
  • 18
  • 32
2
votes
1 answer

The stdafx.h equivalence in Python software development

When the software is getting bigger and bigger it could be hard to have a clean import list for each ".py" file. So the question would spring to mind is, is there any best practice for that. To shed more lights on this issue, assume that we have 5…
Milad Sikaroudi
  • 677
  • 6
  • 16
2
votes
0 answers

Fatal error with afxv_w32.h: WINDOWS.H already included

I am trying to build and run an old (and quite large (approx. 100+ source and header files)) VS project. It was originally compiled using VS2012 and Windows 7, so I am using the same set-up (in fact, both Win 7 and 10). I am new to VS, so please…