[英]Macro function identifier not found
I created an assert marco that works fine but wanted to make one to break.我创建了一个 assert marco ,它运行良好,但想要打破它。 I copied the assert one and renamed it but not it doesn't work when i use it in one header file but it works everywhere else.
我复制了断言并重命名了它,但是当我在一个头文件中使用它时它不起作用,但它在其他任何地方都起作用。
I'm getting this error:我收到此错误:
Severity Code Description Project File Line Suppression State
Error C3861 'RADIANT_TEST_BREAK': identifier not found Sandbox F:\Path\Buffer.h 63
Both macros are in the same file, Core.h which is included wherever i need it.两个宏都在同一个文件 Core.h 中,它包含在我需要的任何地方。
#define RADIANT_CORE_ASSERT(x, ...) { if(!(x)) { RADIANT_CORE_ERROR("Assertion Failed: {0}", __VA_ARGS__); __debugbreak(); } }
#define RADIANT_TEST_BREAK(x, ...) { if(!(x)) { RADIANT_CORE_ERROR("Assertion Failed: {0}", __VA_ARGS__); __debugbreak(); } }
I have no idea why the break one doesn't work in that one place我不知道为什么break one在那个地方不起作用
here is the method i am running it from这是我运行它的方法
struct BufferElement
{
std::string Name;
ShaderDataType Type;
uint32_t Size;
uint32_t Offset;
bool Normalized;
BufferElement(ShaderDataType type, const std::string& name, bool normalized = false)
: Name(name), Type(type), Size(ShaderDataTypeSize(type)), Offset(0), Normalized(normalized)
{
}
uint32_t GetComponentCount() const
{
switch (Type)
{
case ShaderDataType::Float: return 1;
case ShaderDataType::Float2: return 2;
}
RADIANT_TEST_BREAK(false, "Unknown ShaderDataType!");
return 0;
}
};
If i swap RADIANT_TEST_BREAK for RADIANT_CORE_ASSERT It works.如果我将 RADIANT_TEST_BREAK 交换为 RADIANT_CORE_ASSERT 它可以工作。
I found what was causing the problem.我找到了导致问题的原因。
i had the definition in an ifdef but not in the else我在 ifdef 中有定义,但在 else 中没有
#ifdef RADIANT_ENABLE_ASSERTS
#define RADIANT_CORE_ASSERT(x, ...) { if(!(x)) { RADIANT_CORE_ERROR("Assertion Failed: {0}", __VA_ARGS__); __debugbreak(); } }
#define RADIANT_TEST_BREAK(x, ...) { if(!(x)) { RADIANT_CORE_ERROR("Assertion Failed: {0}", __VA_ARGS__); __debugbreak(); } }
#else
#define RADIANT_CORE_ASSERT(x, ...)
//Make sure to include this line
#define RADIANT_TEST_BREAK(x, ...)
#endif
This seems to only be a problem in one place which i still don't know why but this fixed it for me.这似乎只是一个地方的问题,我仍然不知道为什么,但这为我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.