Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 05-22-2004, 08:36 PM   #1
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:





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

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
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, 04:57 AM   #3
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





Or is it still a matter of preferance?

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

Rep: Reputation: 137Reputation: 137
Name it with the name of your program. (eg MyApplication.c)
Old 05-23-2004, 10:29 AM   #5
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, 03:26 PM   #6
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,551

Rep: Reputation: 161Reputation: 161
Preference, but in most cases program name is used.
Old 05-24-2004, 08:49 AM   #7
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:
make hello
This simply does gcc -o hello hello.c


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

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 02: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 10:30 AM
eclipse + CDT : how can i create a project which includes multi main( ) tclwp Programming 4 02-11-2005 09:27 AM
Beginning a big project - Need an Good Project Manager gamehack Programming 3 01-15-2004 12:49 PM
Cannot see Open GL project in KDevelop project wizard SparceMatrix Programming 2 08-08-2002 12:14 AM

All times are GMT -5. The time now is 04:48 AM.

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