【发布时间】:2013-05-26 16:39:11
【问题描述】:
关于在struct 中使用函数的问题。我从 R.Stevens 的书中拿了 sn-p,我看到了几次类似的 sn-ps。我建议获得一些 C 和 Linux 经验,但我真的不知道在这种情况下如何正确使用 struct。
struct stat buf; // The error line
for (i=1; i < argc; i++){
if (lstat(argv[i], &buf) < 0) { // Usage of
err_ret("lstat error");
continue;
}
if (S_ISERG(buf.st_mode))
ptr = "regular";
编译代码时出现错误:
type.c: In function ‘main’:
type.c:9:15: error: storage size of ‘buf’ isn’t known
结构声明有什么问题?我应该明确声明结构大小吗?如果是,我怎么知道?主要问题 - 它是如何工作的struct method name?
【问题讨论】:
-
你有围绕其中一些声明的主程序吗?