Tag: compiler errors

在文件范围错误时修改了’variable_name’?

C的新手。编译时出现以下错误: error: variably modified ‘header’ at file scope error: variably modified ‘sequence’ at file scope 码: struct list{ char header[list_header_size]; char sequence[list_sequence_size]; struct list *next; }; 我认为错误意味着编译器需要从一开始就知道这些变量是什么。 因此,我将main()(调用结构的位置)移动到程序的末尾。 我也尝试在程序开始时声明变量,但我不确定我是否正确地执行了此操作。 我试过char header; 和char header[];

如何修复gcc错误:在void之前预期

所以我正在编写一个使用pthread来管理所有IO的点对点聊天客户端,当我编译文件时,gcc给了我错误 client.c: In function ‘accepted_daemon’: client.c:115:1: error: expected ‘while’ before ‘void’ void * ^ client.c: In function ‘listen_daemon’: client.c:176:1: error: expected ‘while’ before ‘int’ int main(int argc, char *argv[]) ^ 我的程序的源代码是 #include #include #include #include #include #include #include #include #include #define error(s, e, …) error_at_line (s, e, __FILE__, __LINE__, __VA_ARGS__) #include #include #include #include #define […]

如何修复“无法在Turbo C中打开stdio.h”错误?

每当我编译我的程序时,我都会得到上面的错误。

sqrt()函数不能使用变量参数

我不知道我是否遗漏了一些明显的东西,但似乎我无法计算C中变量的平方根; sqrt()函数似乎只适用于常量。 这是我的代码: #include #include int main() { double a = 2.0; double b = sqrt(a); printf(“%f”, b); return 0; } 当我运行此程序时,我收到以下错误: gcc -Wall -o “test2” “test2.c” (in directory: /home/eddy/Code/euler) /tmp/ccVfxkNh.o: In function `main’: test2.c:(.text+0x30): undefined reference to `sqrt’ collect2: ld returned 1 exit status Compilation failed. 但是,如果我将sqrt()中的参数替换为常量(例如b = sqrt(2.0) ( b = sqrt(2.0) ),那么它可以正常工作。 […]