智能感知:标识符"XMFLOAT4"未定义

IntelliSense: Identifier "XMFLOAT4" is undefined

本文关键字:XMFLOAT4 未定义 标识符 感知 智能      更新时间:2023-10-16
    #ifndef RENDERER_H
    #define RENDERER_H
    #pragma once
    #include "Font.h"
    #include "Color.h"
    #undef CreateFont
struct Vertex_t {
    XMFLOAT4 xyzrhw;
    D3DCOLOR color;
    enum {
        FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE
    };
};

当我尝试编译时出现此错误:

智能感知:标识符"XMFLOAT4"未定义。

我该如何解决这个问题?

从您的代码中不清楚您包含<DirectXMath.h>的位置,所以我假设它在 Font.h 或 Color.h 中的某个地方。

DirectXMath 使用 C++ 命名空间DirectX因此应使用:

struct Vertex_t {
    DirectX::XMFLOAT4 xyzrhw;
    D3DCOLOR color;
    enum {
        FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE
    };
};

C++编码建议是避免将using namespace语句放在标头中,而仅将它们保留在.cpp文件的本地。