Problem with header and source files

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with header and source files

1,026 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Thu Jun 18 00:16:01 MST 2015
Hey guys,

my code is now large enough to split it up in single header and source files. They all got the following format:

Header Files:


#ifndef  __example_h
#define __example_h

#define something

void foo(void);

#endif


Source Files (example.c):

#include "example.h"

void foo(void)
{
do something
}


The headerfiles are included at the main sourcefile of the project in following order:

#include "chip.h"
#include "stdlib.h"
#include "stdint.h"

#include "example.h"


The problem is that things that are declared in other headerfiles like variables seem to be unknown in example.h and co.
So i get the following error Messages:

error: unknown type name 'uint8_t'
error: 'LPC_SPI' undeclared (first use in this function)

The Headerfiles are all imported into the inc folder and the source files i added to the src folder.
In the project properties i checked:

C/C++ Build/Settings/Tool Settings/Includes   if the specific inc folder is there. Looks correct for me see attached picture

I think i got something wrong with my project properties. May somebody got an advice how to solve this problem.

best regards

Patrick
Labels (1)
0 Kudos
3 Replies

941 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu Jun 18 03:46:59 MST 2015

Quote:
is this they only possibility to solve this problem.
Because it doesn't seem very handsome to include allways the same headerfiles in other headerfiles



Are you serious? Of course that is what you have to do.

If a header file is dependent on something defined in another header file, it should ALWAYS reference it. Otherwise, somebody using the header file will have to dig around finding all of the headers files they need to include. Take a look a standard C header files to see what I mean.
0 Kudos

941 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Thu Jun 18 02:55:28 MST 2015
Hey R2

is this they only possibility to solve this problem.
Because it doesn't seem very handsome to include allways the same headerfiles in other headerfiles

Regards
0 Kudos

941 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Thu Jun 18 01:02:20 MST 2015
Include stdint.h in your header file :O

Or, if you use LPCOpen, board.h or chip.h...
0 Kudos