LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
 
LinkBack Search this Thread
Old 05-22-2004, 07:36 PM   #1
liguorir
Member
 
Registered: May 2003
Posts: 256

Rep: Reputation: 30
Question main.c vs project.c


When creating a new project that is only one '.c' file,

Should it be named:

project.c

or

main.c

?

Please advise
 
Old 05-22-2004, 07:52 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
It doesn't matter what the filename is. You only need to make sure the main() function is declared in one of your project files. Which file and what filename is compltely arbitrary.
 
Old 05-23-2004, 03:57 AM   #3
liguorir
Member
 
Registered: May 2003
Posts: 256

Original Poster
Rep: Reputation: 30
Question Still need an answer

I know that both would work, I'm trying to establish what the standard is?

For configuration management purposes, and traditional c practices, should the main function be house in

main.c

or

project.c

?

Or is it still a matter of preferance?

Please advise.
 
Old 05-23-2004, 07:30 AM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,282

Rep: Reputation: 66
Name it with the name of your program. (eg MyApplication.c)
 
Old 05-23-2004, 09:29 AM   #5
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
There's no standard, it's just a matter of preference.
 
Old 05-23-2004, 02:26 PM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,527

Rep: Reputation: 147Reputation: 147
Preference, but in most cases program name is used.
 
Old 05-24-2004, 07:49 AM   #7
cjp
Member
 
Registered: Dec 2003
Location: the Netherlands
Distribution: SuSE 9.0
Posts: 54

Rep: Reputation: 15
There is no standard, but using the same name as the program name has an advantage: you can compile your very simple project with the make command without having to write a Makefile. For example, if you saved the "hello world" program as hello.c:
Code:
make hello
This simply does gcc -o hello hello.c
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mirror of The Linux Documentation Project HOWTO's on the main page t3gah LQ Suggestions & Feedback 2 09-15-2008 01:40 AM
(2) Main Menu's? Isn't it, "there can be only one?" for the term "Main"? t3gah LQ Suggestions & Feedback 1 04-09-2005 09:30 AM
eclipse + CDT : how can i create a project which includes multi main( ) tclwp Programming 4 02-11-2005 08:27 AM
Beginning a big project - Need an Good Project Manager gamehack Programming 3 01-15-2004 11:49 AM
Cannot see Open GL project in KDevelop project wizard SparceMatrix Programming 2 08-07-2002 11:14 PM


All times are GMT -5. The time now is 04:00 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration