...
For example, the fputs() defined in §7.19.7 is closely related to the fprintf() defined in §7.19.6. However, the fputs() has the file handle at the end and fprintf() at the beginning as shown by their function declarations.
| Code Block |
|---|
|
int fputs(const char * restrict s, FILE * restrict stream);
int fprintf(FILE * restrict stream, const char * restrict format, ...);
|
The argument order can be easily rearranged using macros, for example:
| Code Block |
|---|
|
#include <stdio.h>
#define fputs(X,Y) fputs(Y,X)
|
...
| Wiki Markup |
|---|
The POSIX ^®^ threads library \[[Butenhof 1997|AA. Bibliography#Butenhof 97]\] defines an interface that is both consistent and fits in with established conventions from the rest of the POSIX library. For example, all initialization functions follow the same consistent pattern of the first argument being a pointer to the object to initialize with the subsequent arguments, if any, optionally providing additional attributes for the initialization: |
| Code Block |
|---|
|
/* initialization of Pthread attribute objects */
int pthread_condattr_init(pthread_condattr_t *);
int pthread_mutexattr_init(pthread_mutexattr_t *);
int pthread_rwlockattr_init(pthread_rwlockattr_t *);
...
/* initialization of Pthread objects using attributes */
int pthread_cond_init(pthread_cond_t * restrict, const pthread_condattr_t * restrict);
int pthread_mutex_init(pthread_mutex_t * restrict, const pthread_mutexattr_t * restrict);
int pthread_rwlock_init(pthread_rwlock_t * restrict, const pthread_rwlockattr_t * restrict);
...
|
...