Papers/programming

redefinition error

tomato13 2007. 6. 27. 11:48

다시 나의 무지함을 공개하게 되었다.

 

<main.cpp>

#include "test.h"

int
main()
{
 func();

 return 1;
}

 

<test.cpp>

#include "test.h"

#define MAX 100

int func2()
{
 func();

 return 1;
}

 

<test2.cpp>

#include "test.h"

int func()
{
 printf("func\n");

 return 1;
}

 

<test.h>

#ifndef _TEST_H_
#define _TEST_H_

#include <stdio.h>

#define MAX 100

int func();
//int i;                      (1)

typedef struct car
{
 char* name;
}sorento;

#endif // _TEST_H_

 

test.h에서 (1)의 주석을 해제하면 compile error가 발생한다. 나름대로의 결로는 변수, 구조체 및 함수등의 선언은 여기저기 가능하지만 정의가 그래서는 안 된다는 것이다.


 

'Papers > programming' 카테고리의 다른 글

함수 포인터  (0) 2007.06.28
void형 변수를 int형으로 타입변환  (0) 2007.06.28
struct pointer  (0) 2007.06.12
enum  (0) 2007.05.16
typedef, callback  (0) 2007.03.17