获取错误代码 C2228:'._Ptr'左侧必须具有类/结构/联合
Getting error code C2228: left of '._Ptr' must have class/struct/union
当我试图执行这行代码时,我得到了这个奇怪的错误代码。
cType += file_size(is_directory( d->status()));
以下是导致错误的部分代码。
void scan(string switches, path const& f, unsigned k = 0)
{
// Declare file types
long long cppType = 0, cType = 0,
hType = 0, hppType = 0,
hxxType = 0, javaType = 0,
totalClassType = 0, aviType = 0,
mkvType = 0, mpegType = 0,
mp4Type = 0, mp3Type = 0;
int cpp = 0, c = 0, h = 0, hpp = 0, hxx = 0, java = 0,
totalClass = 0, avi = 0, mkv = 0, mpeg = 0, mp4 = 0, mp3 = 0;
int totalBytes = 0;
string indent(k, 't');
directory_iterator temp;
directory_iterator d(f); //f = the first file in folder to be processed
directory_iterator e; // signals end of folder
bool isReverse = false;
bool isRecursive = false;
path pth;
pth = d->path();
for (unsigned check = 0; check < switches.size(); ++check)
{
if (switches[check] == 'r')
{
isRecursive = true;
}
else if (switches[check] == 'R')
{
isReverse = true;
}
}
for (unsigned int i = 0; i < switches.size(); ++i)
{
if (switches[i] == 'c')
//OPTION c: Locate c++ files - extension(s): .c,. cpp, .h, .hpp, .hxx
{
if (pth.extension() == ".c")
{
c++;
cType += file_size(is_directory(d->status()));
}
非常感谢您的帮助!
is_directory()返回bool
,而不是Path
,这是file_size()用作参数的内容。
您得到的错误可能意味着file_size()是一个宏,这意味着:
file_size(is_directory( d->status()))
正在扩展到:
is_directory( d->status())._Ptr
由于.
运算符不能应用于bool
值。
相关文章:
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 如何将结构/联合数组的成员传递到函数中
- error dllimport 函数的定义不允许在一个特定的联合中,而其他类、结构和联合将按预期导出
- 为什么继承的结构成员在联合中无法访问?
- 在向量 C++14(无限制联合)的结构内的联合中创建和存储字符串
- 尝试初始化结构内的联合时出错
- 嵌套在联合中的结构嵌套在 C 中的结构中
- 成员引用基类型 'char' 不是 C++ 中的结构或联合
- 结构内部结构的联合 - 混合 C 和 C++
- 联合初始化中的结构
- 成员引用基类型不是结构或联合
- 在结构中使用联合的目的是什么?
- 错误 C2228 左侧'.setDay'必须具有类/结构/联合
- 如何从平面缓冲区中反序列化联合结构的 void* 值的大小
- 联合结构 C# - 等效或等于
- 将C++联合结构转换为 VB6
- C ++:联合 -> 结构,解释?
- 编译器特定联合结构实现的标准替代方案
- 具有构造函数的类的匿名联合/结构
- 联合结构有什么作用