Gast
#992442
Hallo zusammen,
ich habe ein Problem mit #include und #define.
//file: display.h
#include<stdio.h>
void display(int a);
//file: display.cpp
#include "display.h"
void display(int a)
{
printf("a = %d\n", a);
}
//file: control.h
#ifdef MAIN
extern int a;
#else
int a;
#endif
void control();
//file: control.cpp
#include "control.h"
void control()
{
a = 10;
}
//file: test.cpp
#define MAIN
#include "control.h"
#include "display.h"
#undef MAIN
int main()
{
control();
display(a);
return 0;
}
Feher: "int a" ist bereits in control.obj definiert. Mindestens ein
mehrfach definiertes Symbol gefunden.
Kann jemand mir erzählen warum?
Vielen Dank
Gruß