<dirent.h>中的聚合DIR类型是“不完整且无法定义”?

时间:2018-02-06 23:11:38

标签: c++ linux glibc

编译我编写的一段代码时出现问题,该代码使用dirent.h中的调用来与Linux中的目录进行交互。

以下是违规代码:“FoobarClass。

#include "FoobarClass.h"

#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>

#include <cstring>
#include <fstream>
#include <iostream> 

... skipping over unrelated function definitions ...

else
{
    DIR stage_dir;
    stage_dir = opendir(STAGE_DIR);
    if(stage_dir == NULL)
    {
        perror("StageTar");
        result = false;
    }

...
} // end else

显示的错误是

FoobarClass.cpp:218:25: error: aggregate ‘DIR stage_dir’ has incomplete type and cannot be defined

为什么会出现这种情况的想法?当我执行我正在编译的libc.so.6时,我得到了这个。

GNU C Library (GNU libc) stable release version 2.24, by Roland McGrath et al.
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 6.2.0.
Available extensions:
    crypt add-on version 2.1 by Michael Glad and others
    GNU Libidn by Simon Josefsson
    Native POSIX Threads Library by Ulrich Drepper et al
    BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>

0 个答案:

没有答案