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

C naming convention

Name: Anonymous 2010-04-09 3:53

I'm trying to decide on a naming convention for my C library. Do I do pthreads/libpng/etc style, using capital letters only for constants and macros?

typedef struct foo {
  int* bar;
} foo_t;

void foo_init(foo_t* self) {
  self->bar = (int*) malloc(sizeof(int) * 5);
}

void foo_destroy(foo_t* self) {
  free(self->bar);
}


Do I do CamelCase?

typedef struct Foo {
  int* bar;
} Foo;

void FooInit(Foo* self) {
  self->bar = (int*) malloc(sizeof(int) * 5);
}

void FooDestroy(Foo* self) {
  free(self->bar);
}


Or do I do something even more crazy?

I'm definitely leaning towards pure lowercase. It's not really more work to write, and it's a lot easier to read afterwards. Plus it's really consistent with the standard library, among others.

What convention do /prog/lodites use?

Name: Anonymous 2010-04-09 4:51

>>3
Interesting, that's pretty much the opposite of Google style. They use CamelCase for all types, functions and methods, and use lower_case for all variables. (They also forbid the use of shitCase.) Unless you meant CamelCase for types and not variables, in which case your style isn't all that uncommon (it's just ugly.)

Also, what is /prog/'s opinion on the trailing _t? It seems redundant if you properly prefix all your global identifiers, i.e. ns_foo where ns is the acronym for whatever namespace you want. Thoughts?

Name: Anonymous 2010-04-09 5:12

>>4
shitCase is buttugly OOP crap. cant stand it.

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