Including extra .c files compiler error?

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

exit status 1

Compilation error: exit status 1

Please post a minimal but complete example of a sketch that causes the error including any files external to the main sketch file

It is probably being included twice. Post the complete code, and mention whether you have source code tabs open in the IDE.

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.

The .ino file is the sketch file.

I don't find it useful to use source files with .C extensions with the Arduino IDE, and recommend to use .h or .cpp instead.

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

What's special about the .ino file. It's exactly the same as the .c or .cpp file. Why does Arduino rename it?

The .ino is the sketch file. Note the "i" in the extension.

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

Ok, that makes sense. But I still have the problem. Below is are the files in my Arduino directory. Should I rename the .cpp file to .ino?

(ino icon) andy_tft (date and time) INO file
(notepad icon) mstr_clk_buttons.cpp (date and time) C++ Source

Is the .cpp file in the wrong directory. It's not a library so I don't think it would go in that directory?

Post the files, using code tags.

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

Post ALL the code, using code tags.

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.

Whoops !

What I meant to say was
Note that a .cpp file is not actually needed if functions code is put in the .h file

But if I rename the included file to .h, the same error occurs.

See post #11

Why have you not posted this file?

I can begin to guess why you are having trouble, and wish you good luck with the project.