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 13:43

>>9
Yeah um, just because Go is sponsored by Google doesn't mean they actively use it. It's just an experiment right now. Here's Google's real style guide:

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#General_Naming_Rules

Also, doesn't anyone else think that assigning semantic meaning to identifier name style is, well, dumb? I have the same problem with Python's "private" variables by leading with underscores...

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