User forums > Embedded development

2 same files with function main() in workspace-during compilation error.


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.

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.

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.


[0] Message Index

Go to full version