使用gcc
编译两个clang错误来编译终端中的程序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");
}
答案 0 :(得分:0)
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.