c++ - #ifndef 中的结构变灰并且无法被其他源文件访问

标签 c++ visual-studio

我在 ifndef 中有一个结构,它在 visual studio 中是灰色的。它位于一个头文件中,然后包含在另一个 cpp 文件中。 cpp文件无法访问struct,导致编译错误。

我已经在 visual studio 项目的预处理器定义中添加了定义,即 GAME_SHADER_DLL,但运气不好。

这不是我的代码,它来自 sdk 2013 源代码。我已经通过删除定义获得了代码,但是我不知道这会产生什么影响,因为我不了解定义在项目中的作用这么大

// BaseVSShader.h
#ifndef GAME_SHADER_DLL

struct DrawFlashlight_dx90_Vars_t
{
    DrawFlashlight_dx90_Vars_t() 
    { 
        // set all ints to -1
        memset( this, 0xFF, sizeof(DrawFlashlight_dx90_Vars_t) ); 
        // set all bools to a default value.
        m_bBump = false;
        m_bLightmappedGeneric = false;
        m_bWorldVertexTransition = false;
        m_bTeeth = false;
        m_bSSBump = false;
        m_fSeamlessScale = 0.0;
    }
    bool m_bBump;
    bool m_bLightmappedGeneric;
    bool m_bWorldVertexTransition;
    bool m_bTeeth;
    int m_nBumpmapVar;
    int m_nBumpmapFrame;
    int m_nBumpTransform;
    int m_nFlashlightTextureVar;
    int m_nFlashlightTextureFrameVar;
    int m_nBaseTexture2Var;
    int m_nBaseTexture2FrameVar;
    int m_nBumpmap2Var;
    int m_nBumpmap2Frame;
    int m_nBump2Transform;
    int m_nDetailVar;
    int m_nDetailScale;
    int m_nDetailTextureCombineMode;
    int m_nDetailTextureBlendFactor;
    int m_nDetailTint;
    int m_nTeethForwardVar;
    int m_nTeethIllumFactorVar;
    int m_nAlphaTestReference;
    bool m_bSSBump;
    float m_fSeamlessScale;                             // 0.0 = not seamless
};
void DrawFlashlight_dx90( IMaterialVar** params, 
    IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, DrawFlashlight_dx90_Vars_t &vars );

#endif // GAME_SHADER_DLL

// lightmappedgeneric_dx9_helper.cpp
#include "BaseVSShader.h"

// ... Further down in the file

CBaseVSShader::DrawFlashlight_dx90_Vars_t vars; // Has no member DrawFlashlight_dx90_Vars_t

最佳答案

I have added the definition, which is GAME_SHADER_DLL to the pre-processor definitions of the project in visual studio

这意味着它已定义。

#ifndef GAME_SHADER_DLL

如果定义,这将激活代码。

你想要 #ifdef 吗?

关于c++ - #ifndef 中的结构变灰并且无法被其他源文件访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57135854/

相关文章:

c++ - Borland Builder 2007 - 使 TForm 窗口透明

c# - 'Operator Name' 运算符后缺少操作数

c++ - 在 Visual C++ 上使用模板函数时遇到问题

c++ - 每当我调试时出现几个错误

c++ - 无法使用 CMake 和 CUDA 构建共享库

android - 如何使用c/c++代码在android系统下安装apk?

c++ - C++ 命名空间内的外部 "C"链接?

c++ - fastNlMeansDenoising() 不滤除噪声

visual-studio - Visual Studio 中的解决方案文件与项目文件

macos - Visual Studio 可以在带有 ARM 处理器(Apple Silicon)的 Mac 上运行吗