具有类型的静态函数缺少类型说明符
Missing type specifier on a static function with a type
我的问题涉及三个文件以及它们之间的关系:在一个文件中,我有一堆预定义的类型,如Uint
、int32
等。在另外两个中,我有一个类,用于对异常(主要是静态函数)和类的定义进行分类。
所有类型都在文件Types.h
中,其中有一个宏允许全局定义类型:
namespace Enigma {
//Omitted Types
typedef std::uint32_t Uint32;
typedef std::string string;
//Omitted Types
}
#if defined(USING_GLOBAL_TYPES)
using namespace aNamespace;
#endif
在其他文件中,我有以下内容(或者类似的内容):
头文件:
#include "Types.h"
namespace Enigma {
class ExceptionCategory {
typedef Uint32 CategoryID;
static CategoryID GetIDFromName(const string& name) noexcept;
};
}
源文件:
Engima::ExceptionCategory::CategoryID Enigma::ExceptionCategory::GetIDFromName(const string& name) noexcept {
//Omitted Code
}
现在,根据编译器向我抛出的错误消息,问题出现在源文件中,其中包括以下信息:
错误C4430:缺少类型说明符-假定为int。注意:C++不支持默认的int
错误C2143:语法错误:在"&"之前缺少","
错误C2511:"Enigma::ExceptionCategory::IDType Enigma::ExceptionCatalog::GetIDFromName(const int)noexcept":在"Enigma::ExcessionCategory"中找不到重载的成员函数
编辑:主要改写
在cpp文件中,删除命名空间前的双冒号。
aNamespace::int32 aNamespace::aClass::aStaticFunction() noexcept {
//does a thing
}
一个非常简单的错误:
在源代码中string
之前缺少命名空间Enigma
这是不寻常的,因为它已经工作了很长时间,直到突然停止工作
Engima::ExceptionCategory::CategoryID Enigma::ExceptionCategory::GetIDFromName(const Enigma::string& name) noexcept {
//Omitted Code
}
相关文章:
- 缺少类型说明符,显式类型为"缺少错误"
- 与 tesseract::TessBaseApi() 相关的 Tesseract-OCR 出错(预期的类型说明符)
- 为什么转换函数声明不需要至少一个定义类型说明符
- C++需要所有声明的类型说明符和预期的非限定 id(需要调试帮助)
- printf 数据类型说明符复杂问题
- C++错误:"class name"之前的预期类型说明符
- 缺少类型说明符和另一个问题
- 缺少类型说明符 - 假定为 int.注意 c++ 不支持 default-int
- 错误:C4430:缺少类型说明符-假定为int.注意:C++不支持default-int
- 在C++中出现错误之前,无效使用了不完整的类型和所需的类型说明符
- 缺少类型说明符 - int 假定 声明静态成员后出错
- 不能在类型说明符中定义联合
- 没有带有字符串数组的存储类或类型说明符
- 警告:函数使用不带尾随返回类型的'auto'类型说明符
- 仅为某些模板专用化定义转换运算符:预期类型/预期类型说明符
- 在 C++ 中出现unique_ptr错误之前的预期类型说明符
- 有没有办法将类型说明符存储在变量中
- C 期望类对象的类型说明符
- 是无符号的int"简单类型说明符"
- 在 vscode 上编译错误.类型说明符是 C++11 扩展