Duplicate variable declarations I am working on a new project using the LPC824 board and the downloaded lpcxpresso824max_new_project. It built, downloaded and debugged without problems. Initially I am trying to implement a 3-digit 7-segment LED display. I added declarations in peripherals.h and an update routine in main.c. When I build I get two errors - duplicated variable declarations. If I comment them out I get a message "undeclared variable". If I change the name of the variable I get the same duplication error. I have searched every source file in the project and cannot find any duplicates. One of the error messages is: - /Applications/MCUXpressoIDE_25.6.136/ide/plugins/com.nxp.mcuxpresso.tools.macosx_25.6.0.202501151204/tools/bin/../lib/gcc/arm-none-eabi/14.2.1/../../../../arm-none-eabi/bin/ld: ./source/peripherals.o:/Users/julian/Documents/MCUXpressoIDE_25.6.136/workspace/lpcxpresso824max_new_project/Debug/../source/peripherals.h:57: multiple definition of `CA_LUT'; ./source/main.o:/Users/julian/Documents/MCUXpressoIDE_25.6.136/workspace/lpcxpresso824max_new_project/Debug/../source/peripherals.h:57: first defined here Re: Duplicate variable declarations Hello,
Could you please share your peripherals.h file and peripherals.c? Or describe how did you add the declaration for CA_LUT?
Could you please share how did you use CA_LUT in main.c?
Kindly share all the files names in which do you have [#include "peripherals.h"], are those files headers included in main.c?
Best Regards, Luis Re: Duplicate variable declarations Hi,
It could be that, as you define CA_LUT in peripherals.h both the main and peripherals.c call that file giving the duplicate error "multiple definition".
Could you help us try to add the declaration of CA_LUT only in peripherals.c instead of peripherals.h, and retry;
Do you have more declarations as this in peripherals.h? and they have the same error? If you have them please also move them to peripherals.c
Consider your 7 segments as an external peripheral device.
Let me know your findings
Best Regards Re: Duplicate variable declarations This is the entry in peripherals.h for both errors // Lookup table for digits 0-9 (0 = ON, 1 = OFF) const uint32_t CA_LUT[10] = { //0: A, B, C, D, E, F are ON; G, DP are OFF ~((1< // 1: B, C are ON ~((1< // 2: A, B, D, E, G are ON ~((1< // 3: A, B, C, D, G are ON ~((1< // 4: B, C, F, G are ON ~((1< // 5: A, C, D, F, G are ON ~((1< // 6: A, C, D, E, F, G are ON ~((1< // 7: A, B, C are ON ~((1< // 8: All segments ON (A-G) ~((1< // 9: A, B, C, D, F, G are ON ~((1< }; // Global variables holding the current numbers to be printed on Digits 1, 2, and 3 volatile uint8_t display_buffer[3] = {1, 2, 3}; // E.g., displays "123" Both errors are used in main.c :- uint8_t numeric_value = display_buffer[current_digit]; uint32_t segment_pattern = CA_LUT[numeric_value]; #include "peripherals.h" appears only in the following files: - main.c, peripherals.c, AS I mentioned I am coming over from CodeWarrior, so my knowledge of MCUX is probably dangerous (?????). I'm not sure whether a 7-segment display is a peripheral device (peripherals.h and c) or a declaration for a number of pins (pin_mux.h and c), but that can be sorted out later.
記事全体を表示