Problems making my own headers files

support for the ARM toolchain
Post Reply
Nytramr
Posts: 2
Joined: Tue Dec 15, 2009 6:45 pm

Problems making my own headers files

Post by Nytramr » Tue Dec 15, 2009 7:18 pm

Hi,

I’m new in the DS programming (but not new in C programming) and I’m trying to “port” some programs that I wrote in Borland C.

I created a “.h” file, and put it into include directory. This is the file code:

Code: Select all

#ifndef _CARTA_H_
#define _CARTA_H_

#define CARTA_ANCHO 30
#define CARTA_ALTO 50

typedef struct {
  int numero;
  int valor;
  int palo;
  int x;
  int y;
} tyCarta;

void dibujarCarta(u16* b, tyCarta* c);

#endif
Then I created another file, called like the .h but with .c extension. This is the code:

Code: Select all

#include "carta.h"

void dibujarCarta(u16* bank, tyCarta* carta){
//Dibuja la carta en el banco pasado por parámetro
	int i;
	
	for(i = carta->x; i <= carta->x + CARTA_ANCHO; i++){
	  bank[i + carta->y * 256] = RGB15(31,31,31);
	  bank[i + (carta->y + CARTA_ALTO) * 256] = RGB15(31,31,31);
	}
	
	for(i = carta->y; i <= carta->y + CARTA_ALTO; i++){
	  bank[carta->x + i * 256] = RGB15(31,31,31);
	  bank[(carta->y + CARTA_ANCHO)+ i * 256] = RGB15(31,31,31);
	}
}
Then I included my .h into my main code, I tried to compile it and this is the error that I got:

c:/NDS/Demo3/include/carta.h:15: error: expected ')' before '*' token
c:/NDS/Demo3/source/carta.c:3: error: expected ')' before '*' token

Could somebody help me with this? I’d google the error but all links get me to Linux kernel compiling issues.

P.S.: I put this code into the main file and everything works fine, but still I want to create headers files with structs and all stuff :D

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: Problems making my own headers files

Post by elhobbs » Tue Dec 15, 2009 7:55 pm

it looks like it is complaining about u16 not being defined. I am guessing that your main file has other header files included.

RyouArashi
Posts: 29
Joined: Sun Mar 29, 2009 9:23 pm

Re: Problems making my own headers files

Post by RyouArashi » Tue Dec 15, 2009 8:09 pm

Add #include <nds.h> to the include file.

Nytramr
Posts: 2
Joined: Tue Dec 15, 2009 6:45 pm

Re: Problems making my own headers files

Post by Nytramr » Tue Dec 15, 2009 9:33 pm

Thank you very much!!!!
I included the dns.h file and it worked.
It seems that I need more practice with this :P.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests