Strange behavior when building

Joel Sherrill <> joel.sherrill at
Tue Dec 20 15:09:54 UTC 2005

Fabrício de Novaes Kucinskis wrote:
> Hello,
> I'm starting to develop some simple applications with RTEMS to an ERC32 BSP.
> The last one has some .c files and only one header, which I #included in all
> source files (in a way similar to some of the RTEMS examples).
> Sometimes when trying to build, I got a "multiple definition" error. This is
> not related to any specific change I made - I can change, for example, the
> text in a printf call and the error can happen.
> When the error happens, to build my application, I have to:
> 	1. execute a "make clean"
> 	2. comment the "confdefs.h" include
> 	3. execute make (different errors will happen, because there's no confdefs
> inclusion)
> 	4. decomment the "confdefs.h" and
> 	5. execute make again (this time it'll work)
> If I change the includes over the source files (including bsp.h, stdio.h and
> stdlib.h in each one) the problem stops. But I want to understand why this
> is happening, and I would like to avoid including the same set of headers in
> each file.
> There is a snippet of the header:
> 	#ifndef CONFIG_H_ //guard
> 	#define CONFIG_H_
> 	#include <bsp.h>
> 	#include <stdio.h>
> 	#include <stdlib.h>
> 	//Prototypes
> 	rtems_task Interface[...]
> 	rtems_timer_service_routine Timer[...]
> 	boolean VerifyStatus[...]
> 	//RTEMS configuration
> 	[...]
> 	#include <confdefs.h> //this is the line I have to comment when the error

Defining CONFIGURE_INIT actually instantiates data tables.  So it can 
only happen  in one C file.  If you look at the tests and samples, they
are careful to define CONFIGURE_INIT in a single file (usually init.c) 
and then everything is OK.  Otherwise, you get multiple definitions of 
data objects.

I think this is what you are describing -- either no configuration table 
or multiple definitions -- one per file the .h with CONFIGURE_INIT is 
defined in.

> 	#endif /*CONFIG_H_*/
> Any comment will be very appreciated.
> Thank you in advance,
> Fabrício de Novaes Kucinskis - DEA / INPE
> -----------------------------------------
> Divisão de Eletrônica Aeroespacial
> Instituto Nacional de Pesquisas Espaciais

Joel Sherrill, Ph.D.             Director of Research & Development
joel at                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985

More information about the users mailing list