C Etiquette Question

This is a discussion on C Etiquette Question within the C Programming forums, part of the General Programming Boards category; Hey guys its been a while since I've programmed in C (just returned from Java and C#) So I forgot ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    51

    C Etiquette Question

    Hey guys its been a while since I've programmed in C (just returned from Java and C#) So I forgot the etiquette for three things:

    1. Is it alright if my functions that return something start with ret? (e.g. retNumOfBytes, retReads etc.)

    2. In C, do functions typically start lower case and then other word upper case (e.g myFunction, funcTwo)

    3. Is it ok, if my typedefs are all uppercase?

    I'm writing open source code, so I don't want to upset any programmers.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    My opinion:
    1. No
    2. Maybe, just be consistent (but I wouldn't)
    3. Maybe, just be consistent (but I wouldn't)

    gg

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    #2 is called "camel case"
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I would think it's rare for typedefs to be uppercase -- uppercase is generally only for #defines.

  5. #5
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    1) No.
    2) C typically has underscore seperated functions: my_function()
    3) No, typedefs should be lowercase. All uppercase is usually for macros (#define)

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    > I'm writing open source code, so I don't want to upset any programmers.
    You'll always upset some programmers

    In general, only #defines are all uppercase.

    Pretty much everything else is up to you. Most people don't mind so long as you apply your rules consistently.

    Adopt a style you like from other source code perhaps.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    To me it looks cleaner to see the windows style functions of Capitals for every first word.

  8. #8
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    If you are writing code for an established project then you'll want to take a look at their current style and use that. If you are starting your own then just do what feels right.

  9. #9
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    I seem to remember years ago using the convention of all caps for class names. It seems to have fallen out of favor though.

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by Dino View Post
    #2 is called "camel case"
    Is it? Now I know why one of my coworkers started blushing when I refered to her camel toe style. Thanks for clearing that one up, Todd.

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by master5001 View Post
    Is it? Now I know why one of my coworkers started blushing when I refered to her camel toe style. Thanks for clearing that one up, Todd.
    Blushing? Not throwing things? Or yelling?

  12. #12
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    What can I say, I have a way with words. The sensitivity training seminar tickets I won because of a random drawing were pretty awesome though.... hey wait a minute!!

  13. #13
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    I know how that goes. A couple months ago, I was talking with a female coworker, and we were talking about the new female manager. My female coworker mentioned that the new manager was wearing tight white pants on her first day in a mostly-male office.

    I told her, in these exact words, "Tight white pants are hard to pull off". But what I actually meant was from a fashion standpoint, not a "getting her undressed" standpoint. It was quite funny.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  14. #14
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Oh Dino you player you!

  15. #15
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Hahaha! I have never actually had to go to a sensitivity seminar. I think as long as you are not a creepy scoundrel you can jest even about things that are semi-sexual (or even quite sexual) without getting sued by your coworkers.

    On a side-note, is it not a tad uncouth to be patting your own quotes on the back? Though that one is actually quite amusing. So I will give it to you.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21