相关疑难解决方法(0)

使用gcc编译c程序时出现冲突类型错误

我试着用gcc编译以下程序.

0 #include  <stdio.h>
1 
2 main ()
3
4 {    
5  char my_string[] = "hello there";      
6
7  my_print (my_string);    
8  my_print2 (my_string);    
9}
10   
11 void my_print (char *string)
12 {    
13  printf ("The string is %s\n", string);    
14 }
15        
16 void my_print2 (char *string)
17 {
18  char *string2;    
19  int size, i;   
20
21  size = strlen (string);    
22  string2 = (char *) malloc (size + 1);
23
24  for (i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

c gcc

23
推荐指数
3
解决办法
11万
查看次数

x的冲突类型和先前的声明在这里......什么?

当我有时间的时候,我一直在教自己C几个月,我遇到了一个问题我不知道如何解决.

具体来说,当我尝试使用gcc编译它时,我得到:

geometry.c:8: error: conflicting types for ‘trapezoid’
geometry.c:7: note: previous declaration of ‘trapezoid’ was here
geometry.c:48: error: conflicting types for ‘trapezoid’
geometry.c:7: note: previous declaration of ‘trapezoid’ was here
geometry.c:119: error: conflicting types for ‘trapezoid_area’
geometry.c:59: note: previous implicit declaration of ‘trapezoid_area’ was here
geometry.c: In function ‘cone_volume’:
geometry.c:128: error: called object ‘3.14100000000000001421085471520200371742248535156e+0’ is not a function
geometry.c: In function ‘cylinder_volume’:
geometry.c:136: error: called object ‘3.14100000000000001421085471520200371742248535156e+0’ is not a function

现在,我想我可能需要对这些功能进行类型转换,但同样,我不确定.

看起来它想要读取我定义为3.141的PI作为函数.有没有办法可以避免使用魔法数字3.141(虽然它比其他数字少得多)?

//Geometric formulae
#include <stdio.h>
#include <math.h>

#define …
Run Code Online (Sandbox Code Playgroud)

c function void

8
推荐指数
2
解决办法
5万
查看次数

"'的错误冲突类型是什么意思?

我收到一个错误,上面写着"错误:'____'的冲突类型.这是什么意思?

iphone xcode

3
推荐指数
1
解决办法
2万
查看次数

C错误类型冲突

我有以下错误

error : conflicting types for 'sprintf'
error : conflicting types for 'vsprintf'
error : conflicting types for 'vprintf'
error : conflicting types for 'select'
Run Code Online (Sandbox Code Playgroud)

在我的头文件中,代码是

extern char *sprintf(char*,const char*,... )
Run Code Online (Sandbox Code Playgroud)

实际上我包括 #include <stdio.h>

但对于我们写的太阳系

# ifndef HPUX
extern char *sprintf(char*,const char*,... )
Run Code Online (Sandbox Code Playgroud)

c

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

c ×3

function ×1

gcc ×1

iphone ×1

void ×1

xcode ×1