- when passing arrays as pointers, include passing the length.
- function handleBuffer( char*buffer, size_t length );
- conventions in C libraries typically follow
- (destination, source) as in destination = source;
- (state object, int arguments ) as in the state object for the function should be the first parameter.
- putImage( Image *imageOnto, Image *imageSource, int x, int y );
- sendTCP( PCLIENT socket, POINTER buffer, size_t length );
- There is an exception that fread/fwrite is (buffer
- it's always safe consider string literals are 'const char []', the converse is not true. While by the standard they are 'char[]'. They are treated in many implementations as data that can be put into read-only/unwritable (constant) memory. - string literals are arrays because sizeof "1234" returns the size of the array. - "1234"[1]='5'; is left open in the standard as an undefined behavior.
- Preprocessor commands might be indented like this
#if defined( _WIN32 ) || defined( __CYGWIN__ )
# define _GetMyThreadID() ( (( ((uint64_t)GetCurrentProcessId()) << 32 ) | ( (uint64_t)GetCurrentThreadId() ) ) )
# define GetMyThreadID() (GetThisThreadID())
#else
// this is now always the case
// it's a safer solution anyhow...
# ifndef GETPID_RETURNS_PPID
# define GETPID_RETURNS_PPID
# endif
# ifdef GETPID_RETURNS_PPID
# ifdef __ANDROID__
# define GetMyThreadID() (( ((uint64_t)getpid()) << 32 ) | ( (uint64_t)(gettid()) ) )
# else
# define GetMyThreadID() (( ((uint64_t)getpid()) << 32 ) | ( (uint64_t)(pthread_self()) ) )
# endif
# else
# define GetMyThreadID() (( ((uint64_t)getppid()) << 32 ) | ( (uint64_t)(getpid()|0x40000000)) )
# endif
# define _GetMyThreadID GetMyThreadID
#endif
``