視覺作業室 2022:
我想在我的 .cpp 檔案中包含預編譯頭檔案,但我不知道是否值得,因為我還需要包含一個非預編譯頭檔案,該頭檔案與預編譯頭檔案中的頭檔案幾乎相同。
非預編譯頭檔案會使用預編譯頭檔案還是會在每次編譯時再次生成代碼?
共產黨:
#pragma once
#include "Precompiled.h"
#include "No-Precompiled.h" // Basic Headers: Windows.h, Psapi.h
int main()
{
// Functions that I need from "No-Precompiled.h" but I can't Precompile it since changes in it are made on regular basis
}
無預編譯.h:
#pragma once
#include <windows.h>
#include <Psapi.h>
#include <d3d11.h>
class Template
{
public:
//Functions that need many same Headers.
}
預編譯的.h:
#pragma once
#include <windows.h>
#include <Psapi.h>
#include <d3d11.h>
#include <limits>
#include <complex>
#include <filesystem>
#include <iostream>
#include <string>
#include <chrono>
#include <thread>
#include <tchar.h>
#include <wincred.h>
#include <complex>
#include <math.h>
- 我應該只預編譯 .cpp 檔案使用的頭檔案(不多)還是有辦法允許非預編譯頭檔案使用預編譯頭檔案?
uj5u.com熱心網友回復:
使用預編譯的頭檔案并沒有太大變化。特別是,頭球后衛繼續作業。的標頭保護<windows.h>也包含在預編譯狀態中。因此,當編譯器<windows.h>第二次看到時,它會立即被跳過。
在您的情況下,No-Precompiled.h標題結果非常簡單,因為它的所有標題都已包含在內。你只是在編譯Template.
不過,我想知道一些特定的預編譯頭檔案集。PSapi 和 DirectX 和 IOstream?我真的無法想象一個大程式,你有很多檔案都在使用它們。請注意,這<iostream>實際上是 about std::cout,這對 DirectX 程式沒有多大意義。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/476837.html
下一篇:如何制作標題畫面?
