【发布时间】:2016-11-11 03:50:21
【问题描述】:
我正在尝试学习 DirectX 11,目前正在研究照明。我需要在场景中添加一个定向光,但是当我设置我的 LightHelper.h 文件时,它拒绝编译。它抛出错误X1507“无法打开源文件:Windows.h”。
我尝试卸载 Windows SDK 并重新配置一些包含选项,但无济于事。这是我的头文件代码。
#pragma once
#include <Windows.h>
#include <DirectXMath.h>
struct DirectionalLight
{
DirectionalLight()
{
ZeroMemory(this, sizeof(this));
}
DirectX::XMFLOAT4 Ambient;
DirectX::XMFLOAT4 Diffuse;
DirectX::XMFLOAT4 Specular;
DirectX::XMFLOAT3 Direction;
float Pad;
};
struct Material
{
Material()
{
ZeroMemory(this, sizeof(this));
}
DirectX::XMFLOAT4 Ambient;
DirectX::XMFLOAT4 Diffuse;
DirectX::XMFLOAT4 Specular;
DirectX::XMFLOAT4 Reflect;
};
这不是 Windows.h 的唯一头文件(当然),但所有其他的链接都没有问题......我已经尝试了几天了。比较烦人。
谢谢
编辑:这些是我尝试过的解决方案。
我还尝试在“C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\”中查找直接文件路径。它只是引发了另一个错误,即无法包含来自 Windows.h 的另一个标头。我认为是“excpt.h”
【问题讨论】:
-
不用大写的W试试
-
它会抛出同样的错误。 :(
-
不同的项目会发生什么?一个简单的小hello world,包含windows.h只是为了看看它是否可以?
-
创建了一个空白项目并按照您的建议进行操作 - 一个快速的 hello world - 并且没有弹出错误。
-
听起来 IDE 还可以。项目中有问题。您是从头开始制作该项目,还是从 Internet 下载并可能期待不同的工具布局或 Visual Studio 版本?
标签: c++ windows sdk include directx-11