-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid of multiple definition errors #41
Conversation
__TFT_LIB_C__ definition must be before inclusion of "tft_lib.h"
Pointers to driver dependent functions should be declared es "extern" everywhere we #include this header file, but once - as pointers linker should reserve in memory - if this #include was from tft_lib.c file.
No error in my environment. You are doing something wrong.
|
No, i don't think so. Look, up to "png.a make success" message I got the same, but when demo.c start to compiling, I receive errors: |
This is my environment.
|
The version of GCC has changed. "Multiple definition of" on GCC 10.2.1 but not GCC 8.3.0 There was a change in behaviour about global variables between GCC 8.3.0 and GCC 10.2.1. GCC 8.3.0 has a collaborative definition, so no error occurs. Thank you for reporting and your code. Your code has helped me a lot. Try latest. |
Glad to make my modest contribution. Thank you. |
We do #include tft_lib.h throughout the program, and the tft.h file has its own protection against multiple inclusion: #ifndef __TFT_LIB_H__ . However, this protection fails when we first include the tft_lib.h file when building the driver.a library and then try to build the main program that also #includes tft_lib.h along with the library driver.a .
Global vars (*DrawPixel ... *InversionOn) which we declare in this tft_lib.h file should be declared only once as "global vars" . And additionally we can include them as =external= variables in as many files as we want.
The *.c file name, consonant with the name of the tft_lib.h, I mean tft_lib.c, suggests that for any set of modules in the final program, where the tft_lib.h file is included, this set will always have the tft_lib.c module. So, we do declare global vars when we include tht_lib.h to tft_lib.c and do extern vars declarations when we include tft_lib.h to other *.c files.