Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

[style] one-line functions in C

Name: Anonymous 2010-04-11 13:03


int frozen(int arg)
{
  return (arg+23);
}


OR


int frozen(int arg)
{ return (arg+23); }

int frozen(int arg)
  { return (arg+23); }


OR MAYBE EVEN SCREEN ESTATE SAVING


int frozen(int arg) { return (arg+23); }


The first version would be consistent myth my usual style, but version 2.2 looks too sweet to resist.

Name: Anonymous 2010-04-11 14:59

I write real code so we actually use the same standard on all functions.

// style.h
#define RETURN_TYPE
#define FUNCTION_NAME
#define PARAMETERS (
#define PROTOTYPE );
#define DEFINITION_BEGIN ){
#define DEFINITION_END }

// frozen.h
RETURN_TYPE   int
FUNCTION_NAME frozen
PARAMETERS    int arg
PROTOTYPE

// frozen.c
RETURN_TYPE   int
FUNCTION_NAME frozen
PARAMETERS    int arg
DEFINITION_BEGIN
   return arg + 23;
DEFINITION_END

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List