Parenthesis error in debug

This is a discussion on Parenthesis error in debug within the C Programming forums, part of the General Programming Boards category; Hi, recently started programming in C. Currently using the book "Programming in C". However, i'm already running into troubles. Code: ...

  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
    21,450
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    2,698
    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,295
    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, 08:36 PM
  3. Replies: 3
    Last Post: 11-11-2003, 02:44 AM
  4. find where the missing parenthesis are?
    By the Wookie in forum C++ Programming
    Replies: 5
    Last Post: 03-21-2003, 08:57 PM
  5. two arguments own parenthesis?.!
    By Shadow12345 in forum C++ Programming
    Replies: 3
    Last Post: 05-12-2002, 08:51 PM

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