file name extensions with C++?


Results 1 to 14 of 14

Thread: file name extensions with C++?

  1. #1
    Join Date
    Mar 2003
    Location
    UK
    Posts
    621

    file name extensions with C++?

    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.
    MI6, Offensive Information, Hackers, Encryption, UFO, AOL, Infowar, Bubba, benelux, Ufologico Nazionale, domestic disruption, 15kg, DUVDEVAN, debugging, Bluebird, Ionosphere, Keyhole, NABS, Kilderkin, Artichoke, Badger, spookwords, EuroFed, SP4, Crypto AG – a few, alleged, Echelon keywords. Please add some to your email signature. Full list: http://www.serendipity.li/cia/bz1.html
    http://www.nosoftwarepatents.com/

  2. #2
    Join Date
    Sep 2002
    Location
    Harlow, UK
    Posts
    1,788
    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?
    If you have to ask why you want to install Linux, then perhaps you shouldn't.
    -- Michael D. Watts (Gone but never forgotten)

    Linux is not Windows | Posting Guidelines

    Code Monkey (YouTube)

  3. #3
    Join Date
    Jan 2003
    Location
    México
    Posts
    335
    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:

    Code:
    syntax on
    And compile with:

    Code:
    g++ -o example main.c++
    and run with:

    Code:
    [$] ./example
    From any terminal.

    Good luck and happy hacking!!!

  4. #4
    Join Date
    Sep 2003
    Location
    Rochester, MN
    Posts
    3,604
    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.

  5. #5
    Join Date
    Aug 2006
    Posts
    180
    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.

  6. #6
    Join Date
    Sep 2002
    Location
    Harlow, UK
    Posts
    1,788
    Quote Originally Posted by asarch
    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?
    If you have to ask why you want to install Linux, then perhaps you shouldn't.
    -- Michael D. Watts (Gone but never forgotten)

    Linux is not Windows | Posting Guidelines

    Code Monkey (YouTube)

  7. #7
    Join Date
    Sep 2005
    Posts
    681
    i am taking a c++ class and we are taught to save filename with .cpp extension.
    "Software is like sex: it's better when its free."
    -LINUS TORVALDS

  8. #8
    Join Date
    Jan 2006
    Location
    UK
    Posts
    121
    Quote Originally Posted by lugoteehalt
    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.

  9. #9
    Join Date
    Jan 2003
    Location
    México
    Posts
    335
    Quote Originally Posted by deathadder
    I've never seen header files called that before, where about did you see those?
    From Nautilus's extensions.

  10. #10
    Join Date
    Oct 2005
    Location
    Nuernberg, Germany
    Posts
    183
    I was always taught :
    cplusplus source : .cpp
    header: .h
    programname: linux -> no extention, windows-> .exe

  11. #11
    Join Date
    Sep 2002
    Location
    Harlow, UK
    Posts
    1,788
    Quote Originally Posted by asarch
    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.
    If you have to ask why you want to install Linux, then perhaps you shouldn't.
    -- Michael D. Watts (Gone but never forgotten)

    Linux is not Windows | Posting Guidelines

    Code Monkey (YouTube)

  12. #12
    Join Date
    Feb 2004
    Location
    Singapore
    Posts
    2,170
    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.
    Come under the reign of the Idiot King...
    Come to me ... I love linux!

    Registered Linux user: Idiot King #350544

  13. #13
    Join Date
    May 2004
    Posts
    128
    file.cc, file.hh is also used somewhat.

    file.cpp, file.h is the most common.
    "Never ask the barber if you need a haircut."

    Things could be worse...

    YnJldHRfYnVydG9uXzgyQHlhaG9vLmNvbQ== (hidemyemail.net)

    Use the MUTT Mailreader!

  14. #14
    Join Date
    Mar 2003
    Location
    UK
    Posts
    621
    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.
    Last edited by lugoteehalt; 04-16-2007 at 01:06 PM. Reason: it worked.
    MI6, Offensive Information, Hackers, Encryption, UFO, AOL, Infowar, Bubba, benelux, Ufologico Nazionale, domestic disruption, 15kg, DUVDEVAN, debugging, Bluebird, Ionosphere, Keyhole, NABS, Kilderkin, Artichoke, Badger, spookwords, EuroFed, SP4, Crypto AG – a few, alleged, Echelon keywords. Please add some to your email signature. Full list: http://www.serendipity.li/cia/bz1.html
    http://www.nosoftwarepatents.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •