gpt4 book ai didi

c - 两个 gcc clang 错误,无法编译

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

这两个 clang 错误是在终端中使用 gcc 编译程序 file2.c 时给出的:

file2.c:8:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main(){
^
file2.c:22:5: warning: implicit declaration of function 'print' is invalid in
C99 [-Wimplicit-function-declaration]
print("This will print to screen \n\n");
^
2 warnings generated.
Undefined symbols for architecture x86_64:
"_print", referenced from:
_main in file2-d54df1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这两个警告都很好——程序应该仍然可以运行。到底是什么错误?

这是程序file2.c:

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


int globalVar = 100;

main(){

char firstLetter = 'D';

int age = 38;

long int superBigNum = -327670000;

float piValue = 3.12158;

double reallyBigPi = 34234324234;

printf("\n");

print("This will print to screen \n\n");
}

最佳答案

  main(){
^ int is required here. for warning 1

print ("This will print to screen \n\n");
^ function is printf not print, this is the reason, you are getting linker error, Try fixing it.

关于c - 两个 gcc clang 错误,无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32800699/

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