【问题标题】:Eina from EFL incompatible with ftw.h?来自 EFL 的 Eina 与 ftw.h 不兼容?
【发布时间】:2014-01-17 14:38:21
【问题描述】:

我尝试使用 Eina 库的文件模块和经典系统调用。 我的问题是当我想使用 eina 以及 ftw.h 中的一些函数和常量时。

这是第一个简单的代码:

#define _XOPEN_SOURCE 500 /*Get nftw() and S_IFSOCK declarations*/              
#include <ftw.h>                                                                
#include <stdio.h>                                                              
#include <stdlib.h>                                                             
#include <Eina.h>                                                               
/*Compile with                                                                  
gcc -o eina_ftw eina_ftw.c $(pkg-config --libs --cflags eina)                   
*/                                                                              
int main(int argc, char **argv)                                                 
{                                                                               
  int a = FTW_DNR;                                                              
  int b=0;                                                                      
  b = FTW_MOUNT;                                                                
  printf("ok\n");                                                               
  exit(EXIT_SUCCESS);                                                           
}

编译时出现以下错误:

In file included from /usr/include/eina-1/eina/eina_lock.h:50:0,
                 from /usr/include/eina-1/Eina.h:259,
                 from eina_ftw.c:5:
 /usr/include/eina-1/eina/eina_inline_lock_posix.x:57:1: erreur: unknown type name   thread_spinlock_t’
typedef pthread_spinlock_t Eina_Spinlock;
^
/usr/include/eina-1/eina/eina_inline_lock_posix.x:561:4: erreur: unknown type name ‘pthread_barrier_t’
pthread_barrier_t barrier;
^

好的,我试了一下:

#include <Eina.h>  
#define _XOPEN_SOURCE 500 /*Get nftw() and S_IFSOCK declarations*/              
#include <ftw.h>                                                                
#include <stdio.h>                                                              
#include <stdlib.h>                                                             

/*Compile with                                                                  
gcc -o eina_ftw eina_ftw.c $(pkg-config --libs --cflags eina)                   
*/                                                                              
int main(int argc, char **argv)                                                 
{                                                                               
  int a = FTW_DNR;                                                              
  int b=0;                                                                      
  b = FTW_MOUNT;                                                                
  printf("ok\n");
  exit(EXIT_SUCCESS);                                                           
}

现在我遇到了这种错误:

eina_ftw.c: In function ‘main’:
eina_ftw.c:13:7: erreur: ‘FTW_MOUNT’ undeclared (first use in this function)
   b = FTW_MOUNT;
       ^
eina_ftw.c:13:7: note: each undeclared identifier is reported only once for each function it appears in

所以我想知道有没有办法解决这个问题?

【问题讨论】:

    标签: c posix efl


    【解决方案1】:

    设置 _XOPEN_SOURCE 500 (大约相当于)要求 1995 POSIX 声明。

    将其设置为至少 600(对于 POSIX 2001)或 700(对于 POSIX 2008)。

    当然,严格地说,设置_XOPEN_SOURCE 是要求特定版本的 Open Group(最初是 X/Open)单一 Unix 规范,但 POSIX 标准和 Open Group 标准之间存在密切关系。您可以在以下位置了解更多信息:

    【讨论】:

      猜你喜欢
      • 2021-05-20
      • 2016-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      相关资源
      最近更新 更多