LinuxQuestions.org
Visit Jeremy's Blog.
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


View Poll Results: Which extension do you prefer?
.cpp 17 89.47%
.cxx 0 0%
.cc 2 10.53%
.c++ 0 0%
Voters: 19. You may not vote on this poll

Reply
  Search this Thread
Old 08-16-2002, 03:24 PM   #1
boku
Member
 
Registered: Aug 2002
Location: Sweden
Distribution: Gentoo
Posts: 43

Rep: Reputation: 15
Talking cpp, cxx, cc, or c++ !


THE C++ PROGRAMMER'S DILEMMA

Which one to use?
Which one do you prefer?
Please state your reasons!
Please comment upon this important issue!
 
Old 08-16-2002, 04:19 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
There's one left. You have not added .C, that's the one I use.
 
Old 08-16-2002, 04:25 PM   #3
neo77777
LQ Addict
 
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 56
I don't know which one is correct but in my Uni we were taught to use .cpp and .h for headers (no implementation is in headers except inline functions [limited use of inline functions], just plain declaration)
 
Old 08-16-2002, 05:04 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
All of them are correct. All can be found in sources. You use the one you like best.
 
Old 08-17-2002, 03:14 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well surely it's bad to change convention within the same code.. if you're using cpp then surely you should have hpp headers... i'm sure it matters somehow! presumably mara's .C is capital? it has to be very bad practise to use .c for c++
 
Old 08-17-2002, 08:19 AM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Yes, I use capital .C for C++ and .c for C. Works very good for me.
 
Old 08-18-2002, 06:41 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Re: cpp, cxx, cc, or c++ !

Quote:
Originally posted by boku
THE C++ PROGRAMMER'S DILEMMA

Which one to use?
Which one do you prefer?
Please state your reasons!
Please comment upon this important issue!
C, capital c :} ... same as Mara (*nods to the lady...).
But if I *had* to chose from yours (which in my work I naturally won't)
it would be cpp... ;)


Reasons ... Heritage, laziness, the phyical law of cosmic inertia ... :D

Cheers,
Tink
 
Old 08-18-2002, 07:15 PM   #8
Malicious
Member
 
Registered: Jan 2002
Location: Galveston Island
Distribution: suse, redhat
Posts: 208

Rep: Reputation: 30
Using capital C is ok if your code is only used on some *nix box, but it won't work on a windows box since path names are not case sensitive (*.c==*.C).
 
Old 08-19-2002, 08:20 AM   #9
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You're right Malicious, but my code runs only on *nixes (it can be moved, but what for...). SO I don't have this problem.
 
Old 08-19-2002, 02:03 PM   #10
boku
Member
 
Registered: Aug 2002
Location: Sweden
Distribution: Gentoo
Posts: 43

Original Poster
Rep: Reputation: 15
I didn't realize .C was used, and on second thought, it doesn't look that bad either.
However, I can't be that cruel to all the people with inferior OSes, that really have a yen for MY code!
 
Old 08-19-2002, 04:06 PM   #11
Eits0
Member
 
Registered: May 2002
Location: Finland
Distribution: Mandrake 9.0
Posts: 188

Rep: Reputation: 30
Arrow

I used .cpp, and reason is it was easiest to write and clearest to read.

But, I'm not sure will you get same results, but try this anyway:
1. Make some simple C++ program (something like 10 lines)
2. Name it first as program.cpp -> gcc ./program.cpp -o A
3. Then name source file as program2.c++ -> gcc ./program2.cpp -o A
4. Sources were identical, but is it just me or ARE programs compiled from .cpp ending heavier (more bits) than those of .c++ ending???
 
Old 08-19-2002, 04:22 PM   #12
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You should use g++ instead of gcc and in point 3 won't work (no such file ).
 
Old 08-21-2002, 12:18 AM   #13
concoran
Member
 
Registered: Jun 2001
Location: 28N,82W
Distribution: XP,Ubuntu 9
Posts: 473

Rep: Reputation: 30
>Which one to use?
I stick to .cpp, and love it. When I moved from C to C++ (i.e from
structured to OOP, I felt very annoyed at having to name all the
file .cpp as against .c (.c seemed so easy). But gradually got used
to it.

>Which one do you prefer?
always .cpp. No question of .java or .anything or even .C. I love,
eat, breathe, shit cpp.

>Please state your reasons!
Not everything has reasons. I love BMW M3, but can't rationale.

>Please comment upon this important issue!
IMHO, it's not such an important issue, especially on *nix. In M$
windows (VC++), sometimes you have a requrement that your
files be named only .cpp or .cxx, but not in GNU C++.

Rather than wondering what *extentions* people use, I would
ask why kind of programming they do i.e whether OOP or
structured (C).
 
Old 08-21-2002, 02:48 AM   #14
Malicious
Member
 
Registered: Jan 2002
Location: Galveston Island
Distribution: suse, redhat
Posts: 208

Rep: Reputation: 30
Re: cpp, cxx, cc, or c++ !

--Which one to use?
Whatever you want!

--Which one do you prefer?
I really don't have a preference, but I use "cpp" unless I have a good reason not to use it.

--Please state your reasons!
I write code for both Unix/Linux and Windows platforms and sometimes the same code file is used on both. The cpp extension is valid, by default, for both g++ on Linux/Unix and VC6 on Windows. If I used other systems or compilers, I might use another suffix if it was a default across all the systems being used.

Visual C++ generates cpp files and recognizes cpp files as C++ code by default. This can be changed, but is just another step in setting up a project.

GNU Make has builtin rules to compile cpp as C++ code, as well as cc and C. You can add rules for other extensions, but it would add lines to the Makefile.

--Please comment upon this important issue!
Lazy me. One less thing to remember to do when setting up a Makfile or MSVC project.
 
  


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
gcc 4.0.2 v.s. CXX ABI SKelem Linux - Software 2 11-07-2005 04:10 PM
debian dpkg cpp depends on cpp error darkleaf Linux - Software 2 06-25-2004 01:47 AM
cpp: pointers Wonko the Sane Programming 3 11-17-2003 03:38 AM
Questions about CPP and G++ lramos85 Linux - Software 1 10-15-2003 12:30 AM
Now I have gcc/cpp/cpp, but still can't install sfingerh Linux - Software 2 07-30-2002 03:13 AM

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

All times are GMT -5. The time now is 11:00 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