This technique of breaking up code into manageable sub files works fine on other compilers such as the ICC AVR. The button_map is only defined here but Arduino thinks otherwise. The C struct format is also proven good in other compilers. The code below is a condensed .c sub file in the same directory as the .uno file and is included in the base .c file.
C:\Users\adelle\AppData\Local\Temp\2\arduino\sketches\861ADAE8B471FB914FD4E33F84F9371D\sketch\mstr_clk_buttons.c.o (symbol from plugin): In function button_map': (.text+0x0): multiple definition of button_map'
C:\Users\adelle\AppData\Local\Temp\2\arduino\sketches\861ADAE8B471FB914FD4E33F84F9371D\sketch\andy_TFT.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
If included twice, it must be some automatic function of sketch. I specifically only put it in the base code include section. I also tried naming the include file to .cpp and .h but get the same error. I also changed the variable button_map and that didn't work either so it's not a protected name?
I'm not getting this sketch thing? Is sketch the same as a project file in most other IDEs? Is the .uno the sketch file? If opened in notepad, it's just a copy of the base c file.
An Arduino sketch consists of an .ino file plus any other files #included by it. Some of these other files may be in the same folder as the .ino file whilst others, such as libraries will be in other locations that the IDE looks in
In your case I would guess that the sketch would have a single .ino file and a .c file in the same folder
An Arduino sketch file has a setup() and loop() function in it, both of which are called by a hidden main() function that is compiled into the program. The main() function is also responsible for calling functions to set up the Arduino hardware for the type of board being used
Remember that the original purpose of Arduino was to make programming friendly for non programmers
If you have more than one .ino file in the sketch folder than the IDE will automatically combine them before compiling them, No action pr programming statements are required on your part.
However, the preferred method is to use .h and .cpp files in the sketch folder and for the .h file to be #included using quotation marks around the filename to indicate that they are held locally
Note that a .cpp file is not actually needed if functions are put in the .cpp file
I realize I can do that but the idea here is to put the button names in a separate .cpp file so future programmers aren't overwhelmed with a huge single file code listing to simply rename a button.
This is a well practiced procedure and works fine in other embedded IDE packages as well as Visual C.
What is the name of this file in the sketch folder? The extension should be .ino
works fine in other embedded IDE packages as well as Visual C.
Irrelevant. If you are using the Arduino IDE, follow the rules for Arduino IDE. The Arduino IDE is intended for beginners, and while operation is simplified, it not very flexible.