I Make a header file with a function that manipulate cursor positions, text color, etc., and I used it in the main.c
and border.c
. At first it doesn't have a errors but when I used the pyrecc.h
in the border.c
it produce an error in my header file
obj\Debug\main.o||In function `gotoxy':|
E:\C PROJECTS\Ropasci\pyrecc.h|10|multiple definition of `gotoxy'|
obj\Debug\border.o:E:\C PROJECTS\Ropasci\pyrecc.h|10|first defined here|
obj\Debug\main.o||In function `textcolor':|
E:\C PROJECTS\Ropasci\pyrecc.h|20|multiple definition of `textcolor'|
obj\Debug\border.o:E:\C PROJECTS\Ropasci\pyrecc.h|20|first defined here|
obj\Debug\main.o||In function `delay':|
E:\C PROJECTS\Ropasci\pyrecc.h|36|multiple definition of `delay'|
obj\Debug\border.o:E:\C PROJECTS\Ropasci\pyrecc.h|36|first defined here|
pyrecc.h
#ifndef PYRECC_H_INCLUDED
#define PYRECC_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
void gotoxy(int x, int y)
{
COORD c = {0, 0};
c.X = x; c.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
return;
}
void textcolor (int setColor)
{
WORD wColor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
wColor = (csbi.wAttributes & 0xF0) + (setColor & 0x0F);
SetConsoleTextAttribute(hStdOut, wColor);
}
return;
}
void delay(unsigned int mseconds)
{
clock_t spd = mseconds+clock();
while(spd>clock());
}
#endif // PYRECC_H_INCLUDED
border.c
#include <stdio.h>
#include <stdlib.h>
#include "pyrecc.h"
typedef int SCOLOR;
extern const SCOLOR BTborder;
extern const SCOLOR BTtitle;
extern const SCOLOR BTropasci;
extern const SCOLOR WTborder;
extern const SCOLOR WTtitle;
extern const SCOLOR WTropasci;
extern const SCOLOR YTborder;
extern const SCOLOR YTtitle;
extern const SCOLOR YTropasci;
extern SCOLOR Dborder;
extern SCOLOR Dtitle;
extern SCOLOR Dropasci;
void border(int);
void border(int a)
{
if (a==1)
{
system("cls");
}
int i;
gotoxy(5,1);
textcolor(Dborder);
for (i = 0; i < 111; i++)
{
printf("%c", 205);
}
gotoxy(5,28);
for (i = 0; i < 111; i++)
{
printf("%c", 205);
}
for (i = 0; i < 24; i++)
{
gotoxy(1,3+i);
printf("%c", 186);
gotoxy(118,3+i);
printf("%c", 186);
}
}
I tried to omit the #include "pyrecc.h"
in the border.c
file. It runs but it produce a warning in the border.c
.
E:\C PROJECTS\Ropasci\border.c|34|warning: implicit declaration of function 'gotoxy' [-Wimplicit-function-declaration]|
IM A BEGINNER I DONT IF ITS OKAY TO PUT ANOTHER HEADER IN MY OWN HEADER, I STARTED TO WORK IN MULTIPLE SOURCE FILE AND CUSTOMS HEADER ONLY YESTERDAY LOL