multiple main functions

This is a discussion on multiple main functions within the C Programming forums, part of the General Programming Boards category; hi, i was perusing some source code today and came across multiple main functions in two separate files. I was ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    23

    multiple main functions

    hi,

    i was perusing some source code today and came across multiple main functions in two separate files.

    I was wondering how this is possible. Does anybody know of a place I could read more on this.

    Just a curious okie. Any type of feedback is most welcome.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The only likely scenario is that these two files are not forming into one executable, or the main functions are somehow either renamed using macros, or within conditionaly compiled code.

    You can not have two functions by the same name in the same executable. main is not special here, it applies to ALL functions.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    23

    Wink one main writes a save

    well from what i have gathered the one main function is for executing the main prog, while the other main is for writing a save file.

    Can I ask another question, purely hypothetical as I am not that clued up on the subject,
    but have read some articles on the topic,

    Is it possible to wrap C code within python, and thus run two main functions from two separate portions of source.

    Or run one C prog that executes another C prog.

    Thanks for the information, anyhow.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, you can use python to run other programs (or use C to extend python, if you wish to do that, but that requires some special coding to match the Pything interface), and you can use C to start another program if you wish. How you go about these things will depend quite a lot on what you want to achieve and which OS you are using.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program skips functions in main
    By En-Motion in forum C++ Programming
    Replies: 5
    Last Post: 02-18-2009, 09:35 PM
  2. Conversion of pointers to functions
    By hzmonte in forum C Programming
    Replies: 0
    Last Post: 01-20-2009, 01:56 AM
  3. Memory leaks problem in C -- Help please
    By Amely in forum C Programming
    Replies: 14
    Last Post: 05-21-2008, 12:16 PM
  4. Writing to single file in multiple functions
    By alvision in forum C Programming
    Replies: 12
    Last Post: 08-22-2004, 09:15 PM
  5. multiple declarations of functions errors
    By netwizio in forum C Programming
    Replies: 4
    Last Post: 03-07-2004, 09:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21