Thread: Parenthesis error in debug

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    4

    Parenthesis error in debug

    Hi, recently started programming in C. Currently using the book "Programming in C". However, i'm already running into troubles.

    Code:
    #include <stdio.h>
    
    int main (void)
    {
        printf ("Programming is fun.\n");
    
        return 0;
    }
    The debug sends a message explaining that main has a multiple definition.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Are you absolutely sure that that is the entire source code that you compiled?

    Are there any other source files that you are compiling at the same time? For example, if you are using an IDE, you may have multiple source files in your IDE's project, and some other source file could also have another definition of the main function.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    4
    Quote Originally Posted by laserlight View Post
    Are you absolutely sure that that is the entire source code that you compiled?

    Are there any other source files that you are compiling at the same time? For example, if you are using an IDE, you may have multiple source files in your IDE's project, and some other source file could also have another definition of the main function.
    Ah, that seems to be the case. Apparently, it goes wrong when managing multiple source files in a project. Not sure how to change it, running them as seperate files now which seems to be working. Thanks for the tip

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    What IDE are you using? Are you trying to compile a single file or have you created a project?

    Jim

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by Creandum View Post
    Ah, that seems to be the case. Apparently, it goes wrong when managing multiple source files in a project. Not sure how to change it, running them as seperate files now which seems to be working. Thanks for the tip
    If each file builds and runs in a project of its own then clearly each file has its own main, thus they will not work in the same project.
    You have to ask yourself what are you trying to do.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User
    Join Date
    Jan 2013
    Posts
    4
    Quote Originally Posted by jimblumberg View Post
    What IDE are you using? Are you trying to compile a single file or have you created a project?

    Jim
    Codeblocks, i ran it in a project. However, i (tried) to compile the files apart from the other project files. Which does not seem to be working. I'll have to read up in the documentation how to run debug under project files.

  7. #7
    Registered User
    Join Date
    Jan 2013
    Posts
    4
    Quote Originally Posted by iMalc View Post
    If each file builds and runs in a project of its own then clearly each file has its own main, thus they will not work in the same project.
    You have to ask yourself what are you trying to do.
    Yes, when working under a project there a certain things you cannot perform as opposed to working on a "clean file". Which is quite irritating for a beginner, but another experience nonetheless i suppose.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Parenthesis operator overload
    By jack_carver in forum C++ Programming
    Replies: 2
    Last Post: 04-13-2011, 09:25 AM
  2. Debug Error Help! :D
    By CodyHerrick in forum C++ Programming
    Replies: 2
    Last Post: 11-05-2009, 09:36 PM
  3. Replies: 3
    Last Post: 11-11-2003, 03:44 AM
  4. find where the missing parenthesis are?
    By the Wookie in forum C++ Programming
    Replies: 5
    Last Post: 03-21-2003, 09:57 PM
  5. two arguments own parenthesis?.!¿
    By Shadow12345 in forum C++ Programming
    Replies: 3
    Last Post: 05-12-2002, 08:51 PM