<s0****@gmail.comwrote in message news:
>
I'm developing a project which I'm trying to keep as organized as
possible. Since C doesn't support classes, I've been trying to make do
mostly with structs and functions that operate on them. However,
sometimes some of the "higher-level" modules contain functions that
map more or less directly to functions calls in "lower-level" modules.
So I've been having trouble naming these such functions, since ideally
both of them (the one in the higher-level module and the one in the
lower-level module) should have the same names. So, are there any
naming conventions for these cases? Or are there any alternatives for
doing what I'm doing?
If you have, say, EMPLOYEE and CUSTOMER structures in your program, it is
quite likely that both will have getname() functions associated with them.
So use emp_getname() and cust_getname(). It's not ideal. In fact if you use
lcc by Jacob Navia, who posts here, you can get C++ style function
overloading. The problem with the lcc route is that the code will no longer
compile under another C compiler.
I don't think it is my job to either recommend or warn against lcc, but to
point out the issues, then you can make your choice.
Another issue you might consider is that if we have
char *emp_getname(EMPLOYEE *emp)
and
char *cust_getname(CUSTOMER *cust)
then we can't have a fucntion pointer to both
char (*getname)(void *obj)
because EMPLOYEE and CUST *s aren't necessarily the same size as void *s.
However you can write emp_getname() and cust_getname() to take void *s
instead of the real structure type, and convert the parameter in the first
line. Then you can do fancy mapping and polymorphism.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm