我正在构建一个 zipper 应用程序,但它有一个声明,我想将它分离到另一个文件(compress-file.m)中,但只有当我分离文件时,我在使用变量编译时出现错误,请参阅它:
[ubuntu@eeepc:~/Desktop] make
This is gnustep-make 2.0.2. Type 'make print-gnustep-make-help' for help.
Making all for app LeafZip...
Creating LeafZip.app/....
Compiling file main.m ...
main.m: In function ‘main’:
main.m:7: error: ‘PATH_MAX’ undeclared (first use in this function)
main.m:7: error: (Each undeclared identifier is reported only once
main.m:7: error: for each function it appears in.)
main.m:12: warning: implicit declaration of function ‘compressFile’
main.m:7: warning: unused variable ‘outFileName’
make[1]: *** [obj/main.o] Error 1
make: *** [LeafZip.all.app.variables] Error 2
另请参阅 main.m 文件的第 7 行:
char outFileName[PATH_MAX] = { 0 };
并查看一些 compress-file.m 行:
#include <stdio.h>
#include <zlib.h>
#include <limits.h>
/* Buffer to hold data read */
char buf[BUFSIZ] = { 0 };
size_t bytes_read = 0;
gzFile *out = gzopen(outFileName, "wb");
我知道这是 Objective-C 的扩展,但这只是因为当我解决这个问题时,我需要继续使用 Objective-C 进行开发。我需要做什么来纠正这个问题?