Removing extra files generated while creating a dll project in visual studio

682 Views Asked by At

While creating a dll project in VS17, I see multiple files were created on initialization.

enter image description here

But whichever project on C++ I work on, I don't see any such files in their environment. How can I get rid of these files in my environment. Is there any workaround to remove them entirely or reduce these 4 files to one file to reduce mess?

Also before VS17 we used to have stdafx.h, it is mandatory to include this header but in few projects I couldn't find this file, is there any way to remove these initial files entirely?

2

There are 2 best solutions below

1
On BEST ANSWER

When you create a new project in Visual Studio, a precompiled header file named pch.h is added to the project. (In Visual Studio 2017 and earlier, the file was called stdafx.h.)

For more details about pch.h and stdafx.h, I suggest you could refer to the Doc: Precompiled Header Files

If you couldn't want to use precompiled header file, I suggest you could choose to not use precompiled headers (Configuration Properties > C/C++ > Precompiled Headers).

When you create a dll project, you also directly choose uncheck Precompiled header or check Empty project. enter image description here

enter image description here

2
On

stdafx.h/cpp resp. pch.h/cpp are the default generated files for supporting precompiled headers. If you don't want them you can delete them. In order to compile you then have to go to your project settings Configuration Properties -> C/C++ precompiled headers and change the Precompiled Header setting to Not using Precompiled Headers.

Before you delete thos files, you should check the cpp/h file and put the include files into your files.