...
Code Block | ||||
---|---|---|---|---|
| ||||
#ifndef PORTNUMBER /* Might be passed on compile line */ # define PORTNUMBER 1234 #endif #ifndef HOSTNAME /* Might be passed on compile line */ # define HOSTNAME "localhost" #endif /* ... */ LDAP *ld = ldap_init(HOSTNAME, PORTNUMBER); if (ld == NULL) { perror("ldap_init"); return(1); } |
Exceptions
DCL06-C-EX1: Although replacing numeric constants with a symbolic constant is often a good practice, it can be taken too far. Remember that the goal is to improve readability. Exceptions can be made for constants that are themselves the abstraction you want to represent, as in this compliant solution.
...