Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.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
未定义对`\u fcloseall';_C_Windows - Fatal编程技术网

未定义对`\u fcloseall';

未定义对`\u fcloseall';,c,windows,C,Windows,我在编译程序时遇到困难。 错误消息是:未定义对“\u fcloseall”的引用,我认为它可能在开始时丢失了库文件。知道我在Windows8.1+Cygwin上编程也可能很有用。哪个图书馆可能丢失了,或者你发现了其他错误吗 代码如下: #include <stdio.h> #include <assert.h> #include <stdlib.h> void cleanup1(); void cleanup2(); int main(int argc,

我在编译程序时遇到困难。 错误消息是:未定义对“\u fcloseall”的引用,我认为它可能在开始时丢失了库文件。知道我在Windows8.1+Cygwin上编程也可能很有用。哪个图书馆可能丢失了,或者你发现了其他错误吗

代码如下:

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>


void cleanup1();
void cleanup2();

int main(int argc, char *argv[])
{
    FILE * file;
    if(argc < 2){
        printf("\ncommand bsp10085 <file>");
        exit(1);
    }
    assert(atexit(cleanup1) == 0);
    assert(atexit(cleanup2) == 0);
    if((datei = fopen(argv[1], "r")) != NULL){
        printf("\nfile %s is being processed ..",argv[1]);
        fclose(datei);
    }
    else
        printf("\nfile '%s' is missing. ", argv[1]);
}

void cleanup1(){
    printf("\nCleanup the rest");
}

void cleanup2(){
    printf("\nClose all open files");
    fflush(NULL);
    _fcloseall();
}
#包括
#包括
#包括
空洞清理1();
空洞清理2();
int main(int argc,char*argv[])
{
文件*文件;
如果(argc<2){
printf(“\n命令bsp10085”);
出口(1);
}
断言(atexit(cleanup1)==0);
断言(atexit(cleanup2)==0);
if((datei=fopen(argv[1],“r”)!=NULL){
printf(“\n正在处理文件%s..”,argv[1]);
fclose(datei);
}
其他的
printf(“\n缺少文件'%s'”,argv[1]);
}
无效清除1(){
printf(“\n清除其余部分”);
}
空洞清理2(){
printf(“\n关闭所有打开的文件”);
fflush(空);
_fcloseall();
}

我试图编译你的代码(虽然是在ubuntu中),但我也得到了一个警告:警告:函数“fcloseall”[-Wimplicit function declaration]fcloseall()的隐式声明

我想如果你加上

#define _GNU_SOURCE 
以前

#include<stdio.h> 
#包括
你的程序应该运行良好。这是我更改其他一些警告后的代码:

#define _GNU_SOURCE
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>

void cleanup1();
void cleanup2();

int main(int argc, char *argv[])
{
    FILE *datei;
    if(argc < 2){
        printf("\ncommand bsp10085 <file>");
        exit(1);
    }
    assert(atexit(cleanup1) == 0);
    assert(atexit(cleanup2) == 0);
    if((datei = fopen(argv[1], "r")) != NULL){
        printf("\nfile %s is being processed ..",argv[1]);
        fclose(datei);
    }
    else
        printf("\nfile '%s' is missing. ", argv[1]);
   return 0;
}

void cleanup1(){
    printf("\nCleanup the rest");
}

void cleanup2(){
    printf("\nClose all open files");
    fflush(NULL);
    fcloseall();
}
定义GNU源
#包括
#包括
#包括
空洞清理1();
空洞清理2();
int main(int argc,char*argv[])
{
文件*datei;
如果(argc<2){
printf(“\n命令bsp10085”);
出口(1);
}
断言(atexit(cleanup1)==0);
断言(atexit(cleanup2)==0);
if((datei=fopen(argv[1],“r”)!=NULL){
printf(“\n正在处理文件%s..”,argv[1]);
fclose(datei);
}
其他的
printf(“\n缺少文件'%s'”,argv[1]);
返回0;
}
无效清除1(){
printf(“\n清除其余部分”);
}
空洞清理2(){
printf(“\n关闭所有打开的文件”);
fflush(空);
fcloseall();
}

提前感谢您的帮助:)Klay626我想应该是
fcloseall()
,而不是
\u fcloseall()
。您可能还需要。您是否使用
gcc-Wall…
进行编译,并收到任何警告?这是Cygwin的旧版本吗?这个链接提到不久前添加的
fcloseall()
\u fcloseall\u r()
,我刚刚用fcloseall尝试过,它基本上给了我相同的错误。我想一定是版本有问题。顺便说一句,已经将部件更正为“文件”,其中有“datei”。这很奇怪,我从3个月后才开始使用cygwin,这意味着它应该包含在实际版本中。不幸的是,没有工作,仍然出现相同的错误:(