scala-native icon indicating copy to clipboard operation
scala-native copied to clipboard

SN .c file 'is_this_os_unix-like' include has grown shaggy.

Open LeeTibbert opened this issue 1 year ago • 0 comments

The #include statement in many posixlib, probably clib, and possibly other .c files which tests at compile time for "is this operating system unix-like?" has grown by accretion over the years.

According to the renowned Swiss child psychologist Jean Piaget, extensive periods of assimilation (accreting the existing) leads to a demand for accomodation (changing to a new schema).

PR #3817 adds OpenBSD in the same manner as the generation before it and the generation before that. Understandable & perhaps applaudable in a porting effort. The result is that the definition has gone beyond almost unreadable to definitely shaggy, even to someone with years of experience reading .c include statements.

The fact that the SN c coding style does not allow indented nested includes does not help the matter.

As a rapid sketch I suggest something like:

// Any line which is longer than about 40 characters is a code_smell/eye_sore.
// Any line which is longer than 80 characters is just an offense.

// Even this should be broken down into finer _IS_LINUX _IS_MACOS 
#define OS_IS_UNIX_LINK   defined(a) ||  defined(b) ||  defined(z) || defined(__FREEBSD__) || defined (__OPENBSD__)

#if OS_IS_UNIX_LIKE
#elif defined (__WIN32_)
#elif defined (mumble)
#  error "operating system not supported"

LeeTibbert avatar Mar 09 '24 23:03 LeeTibbert