LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   main.c vs project.c (https://www.linuxquestions.org/questions/programming-9/main-c-vs-project-c-184640/)

liguorir 05-22-2004 07:36 PM

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

Dark_Helmet 05-22-2004 07:52 PM

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.

liguorir 05-23-2004 03:57 AM

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.

keefaz 05-23-2004 07:30 AM

Name it with the name of your program. (eg MyApplication.c)

llama_meme 05-23-2004 09:29 AM

There's no standard, it's just a matter of preference.

Mara 05-23-2004 02:26 PM

Preference, but in most cases program name is used.

cjp 05-24-2004 07:49 AM

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


All times are GMT -5. The time now is 03:02 AM.