Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Two main methods?

Two main methods?

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionsysadminhelptutorial
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agetina
    wrote on last edited by
    #1

    I work with DevC++ and i want to make a project with several c++ files. For example i have two c++ files with two main(). Is it possible? How can i build (run) this? - it takes me an error message. ( I have seen a project with two main but it is created in visual c++ not in devc++ and he build very well and every .cpp file generate it's .exe file (program for client server) When i try to create the same project in Dev C++ i can't build!!! What can i do? ) Thank you!

    C CPalliniC K R 4 Replies Last reply
    0
    • A agetina

      I work with DevC++ and i want to make a project with several c++ files. For example i have two c++ files with two main(). Is it possible? How can i build (run) this? - it takes me an error message. ( I have seen a project with two main but it is created in visual c++ not in devc++ and he build very well and every .cpp file generate it's .exe file (program for client server) When i try to create the same project in Dev C++ i can't build!!! What can i do? ) Thank you!

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      A executable with two main methods ? It doesn't make a lot of sense to me: when it is executed, which function should be called ? :doh:

      Cédric Moonen Software developer
      Charting control [v2.0] OpenGL game tutorial in C++

      1 Reply Last reply
      0
      • A agetina

        I work with DevC++ and i want to make a project with several c++ files. For example i have two c++ files with two main(). Is it possible? How can i build (run) this? - it takes me an error message. ( I have seen a project with two main but it is created in visual c++ not in devc++ and he build very well and every .cpp file generate it's .exe file (program for client server) When i try to create the same project in Dev C++ i can't build!!! What can i do? ) Thank you!

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        agetina wrote:

        For example i have two c++ files with two main(). Is it possible? How can i build (run) this? - it takes me an error message.

        You application must have just one entry point. What is the purpose of two main() functions? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        • A agetina

          I work with DevC++ and i want to make a project with several c++ files. For example i have two c++ files with two main(). Is it possible? How can i build (run) this? - it takes me an error message. ( I have seen a project with two main but it is created in visual c++ not in devc++ and he build very well and every .cpp file generate it's .exe file (program for client server) When i try to create the same project in Dev C++ i can't build!!! What can i do? ) Thank you!

          K Offline
          K Offline
          KarstenK
          wrote on last edited by
          #4

          You can only have one main() function. If you want 2 operation modes, you can control it via a start parameter one the commando line which got operated in your one and only main() function. :-\

          Press F1 for help or google it. Greetings from Germany

          1 Reply Last reply
          0
          • A agetina

            I work with DevC++ and i want to make a project with several c++ files. For example i have two c++ files with two main(). Is it possible? How can i build (run) this? - it takes me an error message. ( I have seen a project with two main but it is created in visual c++ not in devc++ and he build very well and every .cpp file generate it's .exe file (program for client server) When i try to create the same project in Dev C++ i can't build!!! What can i do? ) Thank you!

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #5

            You cannot have two main functions (main function is the entry point). You can, however, run an additional thread.

            It is a crappy thing, but it's life -^ Carlo Pallini

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups