相关疑难解决方法(0)

为什么使用预编译头(C/C++)?

快速提问 - 为什么要使用预编译标题?

编辑:阅读回复,我怀疑我一直在做的事情有点愚蠢:

#pragma once

// Defines used for production versions

#ifndef PRODUCTION
#define eMsg(x) (x) // Show error messages
#define eAsciiMsg(x) (x)
#else
#define eMsg(x) (L"") // Don't show error messages
#define eAsciiMsg(x) ("")
#endif // PRODUCTION

#include "targetver.h"
#include "version.h"

// Enable "unsafe", but much faster string functions
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS

// Standard includes
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <direct.h>
#include <cstring>
#ifdef _DEBUG
#include <cstdlib>
#endif

// Standard Template Library
#include <bitset>
#include …
Run Code Online (Sandbox Code Playgroud)

c++ precompiled-headers

42
推荐指数
5
解决办法
3万
查看次数

预编译标题

我有一个示例项目(不是我的)在Visual C++ 6中.我正在尝试将其转换为Visual Studio 2008.

旧项目使用预编译头.现在的问题是:

  1. 什么是预编译头文件?

  2. 由于旧项目使用预编译头.我还将在Visual Studio 2008(新项目)中使用它们.但我得到的错误是"你忘了包含stdafx.h",为了解决这个问题,我在每个源文件中加入了"stdafx.h".这非常有效.但是旧项目在每个文件中都没有包含"stdafx.h"?那么如何选择退出在每个源文件中包含"stdafx.h".因为不是每个源文件都需要"stdafx.h"中定义的包含文件,所以只有少数文件.怎么做的?

编辑: 如何使用预先设定的标题来解释某些文件?

visual-c++-6 precompiled-headers visual-studio-2008

31
推荐指数
2
解决办法
2万
查看次数