gpt4 book ai didi

c - 编译 .c 文件时,出现以下错误 : error: array type has incomplete element type

转载 作者:行者123 更新时间:2023-11-30 21:42:42 25 4
gpt4 key购买 nike

这是给我错误的行

struct label labelArray[100];

我觉得它的定义不正确。

如果有帮助的话,这是其余的代码:

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

int main(int argc, char const *argv[]) {
int curr_addr = 0;
int is_instruction = 0;

struct label labelArray[100];

while(1) {
char* buffer = NULL;
size_t size = 0;

if (getline(&buffer, &size, stdin) == -1) {
// end of file
break;
} else {
char* line = buffer;
if (line[0] == '\t') {
// ignore first tab
line++;
}

const char *ptr = strchr(line, ':');
if (ptr) {
int endlabel = ptr - line + 2;
line += endlabel;
}

...

最佳答案

您从未定义过结构标签。如果不先定义类型,则无法定义给定类型的变量。

struct label的定义放在main之前。然后您可以创建该类型的变量。

关于c - 编译 .c 文件时,出现以下错误 : error: array type has incomplete element type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35369873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com