��extern



�����\�[�X�R�[�h���܂����ŕϐ��⃁�\�b�h���g�p����Ƃ��Ɏ��Ɏg���܂��B

�S�t�@�C�����̂ǂꂩ�ɒ�`����Ă���
�錾�������s����`�͍s��Ȃ��錾���@�ł�



��a.c�̕ϐ���\���́A���\�b�h�� extern ���g���Ab.c�Ŏg�p����

��a.c ---------------------------------------

#include <stdio.h>

int i=1;

struct Structure1{
	char *str;
} st1;

void test(char*str){
	i=10;
	st1.str ="st1\n";
	printf("%s\n",str);
}

��b.c---------------------------------------

#include <stdio.h>

extern void test(char*);
extern void test2();
extern int i;

extern struct Structure1{
	char *str;
} st1;

int main(){
	test("test");
	printf("%d\n",i);
	printf(st1.str);
	return 0;
}





���ϐ����w�b�_�[���Œ�`�E�錾�����ꍇ�A�����̃t�@�C���ŃC���N���[�h����ƃG���[���������܂�

�w�b�_�[��include���ꂽ�\�[�X�R�[�h�ɓW�J����邽�߂� int i ���d�����Ē�`����邱�ƂɂȂ�G���[�ɂȂ�
�ȉ��̓G���[�ɂȂ�v���O����

��test.h ---------------------------------------

int i;

��a.c ---------------------------------------

#include <stdio.h>
#include "test.h"

void test(){
	printf("%d\n",i);
}

��b.c ---------------------------------------

#include <stdio.h>
#include "test.h"

extern void test();

int main(){
	i=10;
	test();
	return 0;
}




����̃v���O�����̉��ǔŁ@�w�b�_�[�Ń\�[�X�R�[�h��̂ǂ����ɂ���ϐ��̐錾�������Ă���

��test.h ---------------------------------------

extern int i;

��a.c ---------------------------------------

#include <stdio.h>
#include "test.h"

void test(){
	printf("%d\n",i);
}

��b.c ---------------------------------------

#include <stdio.h>
#include "test.h"

extern void test();

int i;

int main(){
	i=10;
	test();
	return 0;
}




���w�b�_�[�炵����������
�w�b�_�[��include�����\�[�X�t�@�C�����R���p�C������鎞��include���ꂽ�w�b�_�[���e�X�R���p�C������܂�
������C���N���[�h���ꂽ�ꍇ�ł��}�N�����߂ɂ���‚����R���p�C������Ȃ��悤�ɂ��Ă��܂��B


��test.h ---------------------------------------

#ifndef _TEST_
#define _TEST_

extern int i;
extern void test();

#endif

��test.c ---------------------------------------

#include <stdio.h>

int i=0;

void test(){
	printf("%d\n",i);
}

��a.c ---------------------------------------

#include <stdio.h>
#include "test.h"

int main(){
	i=10;
	test();
	return 0;
}




����̃v���O�������C�����č\���̂̐錾���w�b�_�[�ōs�Ȃ�
�w�b�_�[�̒��Ō^�̐錾���s���Ă��邪��`���s�Ȃ��Ă͂����Ȃ��B

��test.h ---------------------------------------

#ifndef _TEST_
#define _TEST_

//typedef�ɂ��(bb)�^��ʂ̖��O(aa)�Ŏg�p�ł���悤�ɂ���
typedef struct bb{
	char*str;
} aa;

extern void test(aa);

#endif

��test.c ---------------------------------------

#include <stdio.h>
#include "test.h"

void test(aa a){
	printf("%s\n",a.str);
}


��a.c ---------------------------------------

#include "test.h"

int main(){
	aa a;
	a.str ="aaa";
	test(a);
	return 0;
}







���g�b�v�y�[�W > Windows �� C++