This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Include Files Problem

Hi Friends,
I'm currently working on C51v6.02 by Keil, My Problem goes like this:

I have a project which has the files file1.c, file2.c, file3.c. And header files header1.h, header2.h, header3.h. The source code of file1.c goes like this.

#include "header1.h"
#include "header2.h"

/* My code */
The source code of file2.c goes like this.

#include "header1.h"
#include "header3.h"

/* My code */
Now when I compile the project the following error message creeps in

*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
    SYMBOL:  VARIABLE_NAME
    MODULE:  File_Name.obj  (FILE_NAME)


My header file header1.h goes this way
#ifndef __HEADER1_H__
#define __HEADER1_H__

/* My Code */
/* Also includes variables */

#endif

but still the same error creeps in. Is there any way to avoid this? What ever I'm doing, is it the corrent way to do it?? Thank you.

With Regards,
Yaswanth

 Proudly wasting time since 1981  

Parents
  • The message tells you the name of the symbol with the multiple definitions; use that to search all your files & spot the repeats!

    The duplicates may not necessarily be in the headers

    I think I've criticised this message before: it's fairly pointless of it to complain about multiple definitions, but then only list one module name!

    Borland C++ Builder would list all the files which defined the offending symbol, thus making your search much easier!

Reply
  • The message tells you the name of the symbol with the multiple definitions; use that to search all your files & spot the repeats!

    The duplicates may not necessarily be in the headers

    I think I've criticised this message before: it's fairly pointless of it to complain about multiple definitions, but then only list one module name!

    Borland C++ Builder would list all the files which defined the offending symbol, thus making your search much easier!

Children