分离要组织的代码
我正在构建一个拉链应用程序,但它有一个声明,我想将其分离到另一个文件(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 中进行开发 - C. 我需要做什么来纠正这个问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PATH_MAX 并不总是通过包含
来定义。如果您想使用它,您可能需要依靠该片段:您是否在主程序中包含了
limits.h
?如果没有,您需要这样做。PATH_MAX is not always defined by including
<limits.h>
. If you want to use it, you probably need to fall back on the fragment:Did you even include
limits.h
in your main program? If not, you need to do so.看起来
main.m
需要#include
。似乎还需要包含一个描述 compressFile 的标头(我猜您已将其移至compress-file.m
中)。Looks like
main.m
needs to#include <limits.h>
. It also seems like it will need to include a header describing compressFile (which I guess you moved intocompress-file.m
.