LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-09-2005, 08:19 PM   #1
tclwp
Member
 
Registered: Jan 2005
Posts: 37

Rep: Reputation: 15
eclipse + CDT : how can i create a project which includes multi main( )


I mean creating a project which includes several *.c source files . More than one *.c file (even each) have main( ) function.


ThanX in advance

Last edited by tclwp; 02-09-2005 at 08:23 PM.
 
Old 02-09-2005, 08:29 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Why do you need these multiple main() functions in one project? You can't compile them all into one binary. There can only be one main function in a program. And, in C, only one function with any given name.
 
Old 02-09-2005, 09:26 PM   #3
tclwp
Member
 
Registered: Jan 2005
Posts: 37

Original Poster
Rep: Reputation: 15
thanks a ton

Thank you for replying
but I use Standard Make C Project and
write my own makefile to resolve the problem
the C files are complied together,
because they work together,
I just want to know how to resolve it in Managed Make C Project

 
Old 02-10-2005, 11:18 PM   #4
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 215

Rep: Reputation: 31
Re: thanks a ton

Quote:
Originally posted by tclwp
Thank you for replying
but I use Standard Make C Project and
write my own makefile to resolve the problem
the C files are complied together,
because they work together,
I just want to know how to resolve it in Managed Make C Project

You may need to research this in your manual but try something like this'
Code:
#ifdef XP
     main()
     /* code for XP
#endif
#ifdef MAC
    main()
    /*code for MAC
#endif
Then let your make file tell the compiler which one to use.
As Matir has said, YOU CAN ONLY HAVE ONE MAIN FUNCTION.
So stated in The C Programming Language by Kernighan and Richie Chapter 1 Section 1.1.
It sets your entry point to the program. It can be the first function or the last function.
 
Old 02-11-2005, 08:27 AM   #5
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
I don't use Eclipse so I can't answer the OP's question, but it sounds like he has a Makefile that has targets to build multiple binaries and he wants to port that into Eclipse.

In Visual Studio parlance, you would have a solution/workspace that contains multiple projects. Perhaps Eclipse has some way of grouping up several projects so that you can have them all open at once? If so, I would look into that and create a project for each binary created in your Makefile.

Last edited by deiussum; 02-11-2005 at 08:28 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse w/CDT plugin - importing existing sorce code kenneho Programming 0 10-29-2005 06:44 AM
Eclipse CDT for Amd64??? ssobeht Programming 4 02-07-2005 06:33 AM
Eclipse CDT for Amd64 pliz?! ssobeht Debian 1 02-05-2005 12:44 PM
autoindent in eclipse/CDT spuzzzzzzz Linux - Software 0 07-23-2004 06:27 PM
main.c vs project.c liguorir Programming 6 05-24-2004 07:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration