#include<stdio.h>
#include<stdlib.h>
#define GREY 1
#define BLACK 0
#define WHITE 2
typedef struct node * graph;
typedef struct stack * snode;
graph cnode(int data); //cnode is to create a node for graph
void cgraph(void);
struct node {
int data, color;
struct node *LEFT, *RIGHT, *TOP, *DOWN;
};//this structure defines a node of the graph
struct stack {
struct stack *priv;
struct cgraph *graph_node;
};// this is to define a structure which should hold node of a structure
extern snode sroot;
Iは、上記のようにヘッダーファイル(declaration.h)を定義し、以下では、交流プログラム(stack.c) ある私は警告
#include<declarations.h>
void cstack (graph temp);
void stackpush(snode stemp);
extern int stack_counter = 0;
sroot=NULL;
void cstack (graph gtemp) //cstack is to create stack
{
snode spriv,some;
if (stack_counter==0)
{
sroot=stackpush(gtemp);
spriv=sroot;
stack_counter++;
}
else{
some=cstacknode(gtemp);
some->priv=spriv;
spriv=some;
}
}
//struct stack is representing a stack
//struct node is representing a node in graph
snode cstacknode (graph gtemp)
//this function should create a node of the stack which should be storing the graph node as a pointer
{
snode an;
an=(snode)malloc(sizeof(snode));
an->graph_node=gtemp;
an->priv=NULL;
return an;
}
void stackpush(snode stemp)
{
}
を開発していライブラリで使用されるであろう作ってい
上記のファイルは両方とも同じディレクトリにあります。 私は私が私が私がその上の警告などの任意の考えていることですか、なぜ私は大胆にマークしているのexternとして変数を宣言したときに知りたいの警告
stack.c:4: warning: ‘stack_counter’ initialized and declared ‘extern’
stack.c:6: warning: data definition has no type or storage class
stack.c:6: error: conflicting types for ‘sroot’
./declarations.h:21: note: previous declaration of ‘sroot’ was here
stack.c:6: warning: initialization makes integer from pointer without a cast
stack.c: In function ‘cstack’:
stack.c:12: warning: passing argument 1 of ‘stackpush’ from incompatible pointer type
stack.c:3: note: expected ‘snode’ but argument is of type ‘graph’
stack.c:12: error: void value not ignored as it ought to be
stack.c:13: warning: assignment makes pointer from integer without a cast
stack.c:17: warning: assignment makes pointer from integer without a cast
stack.c: At top level:
stack.c:27: error: conflicting types for ‘cstacknode’
stack.c:17: note: previous implicit declaration of ‘cstacknode’ was here
stack.c: In function ‘cstacknode’:
stack.c:32: warning: assignment from incompatible pointer type
を以下の上記のファイルstack.c cc -I ./ stack.c
をコンパイルし、残っているエラーで他のものを共有したい場合は、私に知らせてください。
最近の質問[extern変数を宣言とともにどのように定義するのか?](http://stackoverflow.com/questions/24436770/how-to-define-extern-variable-along-with-宣言) –