Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
编译C代码时出现问题_C_Compiler Errors_Mingw_Glibc_Dev C++ - Fatal编程技术网

编译C代码时出现问题

编译C代码时出现问题,c,compiler-errors,mingw,glibc,dev-c++,C,Compiler Errors,Mingw,Glibc,Dev C++,我正在使用Dev-C++4.9.9.2和MinGW来编译以下代码: /* get the information about the group. */ struct group* group_info = getgrnam("PLACEHOLDER"); /* make sure this group actually exists. */ if (!group_info) { printf("group 'PLACEHOLDER' does not exist.\

我正在使用Dev-C++4.9.9.2和MinGW来编译以下代码:

  /* get the information about the group. */
  struct group* group_info = getgrnam("PLACEHOLDER");
  /* make sure this group actually exists. */

  if (!group_info) {
     printf("group 'PLACEHOLDER' does not exist.\n");
  }
  else 
  { 
     char** p_member;

     printf("Here are the members of group 'PLACEHOLDER':\n");
     for (p_member = group_info->gr_mem; *p_member; p_member++)
        printf("  %s\n", *p_member);
     } 
  }
我包含了以下头文件:

  • 玻璃钢
  • sys/types.h
(从Glibc2.13获得的(可能这是错误的,但一位朋友告诉我这是正确的方法))

当我试图编译代码时,glibc的头中会出现一系列错误,如:

12 C:\glibc-2.9\include\sys\cdefs.h expected constructor, destructor, or type conversion before '(' token 
12 C:\glibc-2.9\include\sys\cdefs.h expected `,' or `;' before '(' token 
4  C:\glibc-2.9\include\grp.h expected constructor, destructor, or type conversion before '(' token   
编辑:

这就是全部代码

 #include <grp.h> /* defines 'struct group', and getgrnam(). */
 #include <sys/types.h> /* defines 'gid_t', etc.              */

 BOOL getListOfGroupMembers() {

   /* get the information about the "strange" group. */
   struct group* group_info = getgrnam("PLACEHOLDER");
   /* make sure this group actually exists. */
   if (!group_info) {
      printf("group 'PLACEHOLDER' does not exist.\n");
   }
   else 
   {
      char** p_member;

      printf("Here are the members of group 'PLACEHOLDER':\n");
      for (p_member = group_info->gr_mem; *p_member; p_member++)
      {
        printf("  %s\n", *p_member);
      } 
    }

    return 0;

  }
#include/*定义了“struct group”和getgrnam()*/
#包括/*定义“gid_t”等*/
BOOL getListOfGroupMembers(){
/*获取有关“奇怪”组的信息*/
结构组*group_info=getgrnam(“占位符”);
/*确保此组确实存在*/
如果(!组信息){
printf(“组“占位符”不存在。\n”);
}
其他的
{
char**p_成员;
printf(“以下是组“占位符”的成员:\n”);
对于(p_成员=组信息->gr_成员;*p_成员;p_成员++)
{
printf(“%s\n”,*p_成员);
} 
}
返回0;
}

bool返回现在没有意义,我想在编译works时改变这种情况。

最低的for循环中缺少一个大括号,但这可能只是一个发布错误?

你不能在windows上将几个头文件从glibc带到mingw。这些头文件不是自包含的,它们需要许多其他头文件,甚至可能需要安装在系统上(不只是在glibc源文件夹中引用…)


除此之外,glibc不是为windows设计的-这些头文件是专门为glibc设计的,win32也没有getgrnam()函数。(您需要cygwin,它有自己的头文件)

我怀疑这是问题的根源,但它看起来您的for有一个右括号},但缺少左括号和左括号。

看起来在包含之前您有什么问题。您可以发布这些部分吗?您知道是否有一种方法可以在不使用getgrnam()的情况下获取组(c)中所有用户的列表?