Click to See Complete Forum and Search --> : file name extensions with C++?
lugoteehalt
03-28-2007, 10:06 AM
Got this book, 'Teach Yourself C++', and it says use filename.ccp for source code and filename for the resultant binary. Vim's syntax thing doesn't like .ccp and mc seems to worry about the extension when I try to execute the binaries - it opens vim instead of running them. What is recomended for extensions?
Thanks any help.
deathadder
03-28-2007, 10:20 AM
I always use .cpp for source, .h for headers ofcourse, I always use the filename minus the extension for binaries, but I jus run them from the command line, I don't use mc but can you tell it to just open executables in bash or something like that?
asarch
03-28-2007, 03:42 PM
I would like to suggest this scheme:
main.c++
main.h++
and, most of all, don't forget to add this line to your "~/.vimrc" file:
syntax on
And compile with:
g++ -o example main.c++
and run with:
[$] ./example
From any terminal.
Good luck and happy hacking!!! :D
cybertron
03-28-2007, 03:57 PM
From what I've seen .cpp is the most common extension for C++ files. I've never heard of using ccp before, and it really doesn't make any sense so I'd stay away from it.
Vim's syntax thing doesn't like .ccp
You mean it doens't highlight the CPP code? Try using ":synax on", or add it to your .vimrc
mc seems to worry about the extension when I try to execute the binaries - it opens vim instead of running them.
Try avoiding using the extention 'cpp' for the binary, it doesn't make sense and will only confuse mc. The binary will have to have executable permissions as well.
deathadder
03-29-2007, 02:41 AM
I would like to suggest this scheme:
main.c++
main.h++
I've never seen header files called that before, where about did you see those?
crow2icedearth
03-30-2007, 07:38 PM
i am taking a c++ class and we are taught to save filename with .cpp extension.
chameleon
03-31-2007, 12:26 PM
Got this book, 'Teach Yourself C++', and it says use filename.ccp for source code and filename for the resultant binary.
Are you sure it says ccp? Never heard of that in conjunction with C++ programming.
asarch
04-01-2007, 12:27 AM
I've never seen header files called that before, where about did you see those?
From Nautilus's extensions.
webwolf
04-02-2007, 01:42 AM
I was always taught :
cplusplus source : .cpp
header: .h
programname: linux -> no extention, windows-> .exe
deathadder
04-03-2007, 04:25 AM
From Nautilus's extensions.
You learn something new each day, I can see it having a benefit if you've got to mix sources from older C projects...apart from that I'd find it hard to switch from .h, I'm just stuck in my naming ways it would seem. :)
XiaoKJ
04-03-2007, 10:03 AM
Actually, I think that some filesystems don't like .c++ because it includes non-alphanumeric characters. .cpp and .hpp would be a rather sensible choice.
I'd vote against .h too --- its too C-like to suggest using g++ instead of gcc to compile.
bburton
04-04-2007, 12:37 AM
file.cc, file.hh is also used somewhat.
file.cpp, file.h is the most common.
lugoteehalt
04-05-2007, 01:59 PM
Right, thanks all. I'll try using .cpp, the .ccp was probably my error. By syntax in vim was meant the automatic indenting after a ; and so on.
Get rid of the .ccp for the binary with something like $ basename .ccp, perhaps.
Yes that works.
Vim and mc are happy.