比如你的头文件叫stdafx.h 方法一、 #ifndef _stdafx_h #define _stdafx_h //the header content #endif 方法二、 头文件第一行写下: #pragma once