User forums > Using Code::Blocks

Multiple Definitions (I promise I already searched the forums!)

<< < (2/3) > >>

stahta01:

--- Quote from: EASports on July 14, 2009, 05:51:16 am ---The implicit declarations are only there because I was trying to isolate the problem with the multiple definition errors. If I include "kbhit.h" then the warnings do go away, but the errors remain:

--- End quote ---

Did you re-add it to both main.c and kbhit.c?
Which ones did you define MAIN in?

The error in this case implies MAIN should be defined in kbhit.c.

Tim S

EASports:

--- Quote from: stahta01 on July 14, 2009, 05:56:45 am ---Did you re-add it to both main.c and kbhit.c?

--- End quote ---

It is added in kbhit.c and delta.h, which is included in main.c



--- Quote from: stahta01 on July 14, 2009, 05:56:45 am ---Which ones did you define MAIN in?

--- End quote ---

main() is defined in main.c



--- Quote from: stahta01 on July 14, 2009, 05:56:45 am ---The error in this case implies MAIN should be defined in kbhit.c.

--- End quote ---

really? Which part of the error implies that? How could that have happened?

Thanks!

EASports:
I think I got it. There seemed to be some issue with having a function named kbhit() inside the file named kbhit.c

Anyways, now it's compiling. Thanks a lot for your help!

stahta01:

--- Code: ---#ifdef MAIN
#define EXTERN           // the Main module defines objects
#else
#define EXTERN extern    // others modules see objects as externs
#endif

--- End code ---

The above code means normally define EXTERN as extern; but, in the Main module define it as nothing.
Sometimes the Main modules is the code holding the main() and sometimes it is the "c" file that goes with header.

I am guessing that since you are having issues with kbhit.c errors; that in this case MAIN needs to be defined there. But, it is just a guess!

Where are you defining MAIN?

Tim S

stahta01:

--- Quote from: EASports on July 14, 2009, 06:42:12 am ---I think I got it. There seemed to be some issue with having a function named kbhit() inside the file named kbhit.c

Anyways, now it's compiling. Thanks a lot for your help!

--- End quote ---

Could be an Compiler or linker bug.

Tim S

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version