Code::Blocks Forums

User forums => Embedded development => Topic started by: aorlecki on October 05, 2017, 08:15:06 pm

Title: 2 same files with function main() in workspace-during compilation error.
Post by: aorlecki on October 05, 2017, 08:15:06 pm
I'm working with Code::Block a few days.
Why this happens at C++Editor  Code:: Blocks, after adding additional empty files ( CTR-SHIFT-N  untitled.cpp )  in any projects and copying content from working code from main.cpp in order to have a copy on hand, appears info error: "multiple definitions of `main' "during compiling-Is that mean in this editor is not possible to have  function main() in current project  at each file.
The compiler is working well without error when removing this additional copied files from the project and compiling possible is again.
Title: Re: 2 same files with function main() in workspace-during compilation error.
Post by: oBFusCATed on October 05, 2017, 08:40:37 pm
Because you're not allowed to have two functions named the same in the same executable.

Have to setup multiple projects or multiple targets in a project and then add the two files to two separate projects or targets which build different executables.
Title: Re: 2 same files with function main() in workspace-during compilation error.
Post by: aorlecki on October 05, 2017, 09:24:17 pm
Thanks for helping answer and clarify my fresh approach with Code::Blocks

It is a good thing to have a parallel temporary assistant workspace in using in the main project ->>I will follow Your advice to have separate projects and not for build different executables but for keeping order. You may work without problems to remember when and how to add class or other elements. -It is also a solution for that to have separated programming editor: notepad++ , vim or even any kind of simple notepad to have that in hand during work.
Regards