Click here to Skip to main content
15,946,342 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralCSS & Sophocles, more related than you know Pin
raddevus22-Jul-24 12:22
mvaraddevus22-Jul-24 12:22 
GeneralRe: CSS & Sophocles, more related than you know Pin
Jeremy Falcon22-Jul-24 14:19
professionalJeremy Falcon22-Jul-24 14:19 
GeneralRe: CSS & Sophocles, more related than you know Pin
raddevus22hrs 57mins ago
mvaraddevus22hrs 57mins ago 
GeneralRe: CSS & Sophocles, more related than you know Pin
Jeremy Falcon18hrs 54mins ago
professionalJeremy Falcon18hrs 54mins ago 
GeneralRe: CSS & Sophocles, more related than you know Pin
Jeremy Falcon18hrs 39mins ago
professionalJeremy Falcon18hrs 39mins ago 
GeneralRe: CSS & Sophocles, more related than you know Pin
raddevus18hrs 25mins ago
mvaraddevus18hrs 25mins ago 
GeneralRe: CSS & Sophocles, more related than you know Pin
Jeremy Falcon16hrs 28mins ago
professionalJeremy Falcon16hrs 28mins ago 
GeneralRe: CSS & Sophocles, more related than you know Pin
RickZeeland22-Jul-24 19:13
mveRickZeeland22-Jul-24 19:13 
AnswerRe: CSS & Sophocles, more related than you know Pin
raddevus22hrs 58mins ago
mvaraddevus22hrs 58mins ago 
GeneralRe: CSS & Sophocles, more related than you know Pin
Jeremy Falcon18hrs 51mins ago
professionalJeremy Falcon18hrs 51mins ago 
JokeRe: CSS & Sophocles, more related than you know Pin
Peter_in_278022-Jul-24 20:27
professionalPeter_in_278022-Jul-24 20:27 
GeneralRe: CSS & Sophocles, more related than you know Pin
TNCaver15hrs 19mins ago
TNCaver15hrs 19mins ago 
GeneralRe: CSS & Sophocles, more related than you know Pin
Richard Deeming4hrs 16mins ago
mveRichard Deeming4hrs 16mins ago 
GeneralLinux C PreProcessor: Who Knew? Pin
raddevus4-Jul-24 6:26
mvaraddevus4-Jul-24 6:26 
I'm going through a book right now which is fantastic!
It's the best intro to OSes (how they are designed/programmed) I believe you'll ever read.

First of all, you can read it for FREE online (PDFs).
Operating Systems: Three Easy Pieces[^]

Have you read the book? It's fantastic because it starts out with simple code examples (in C) that teach one specific point at a time. Amazing!

If you've never read it, please skip all the (intro nonsense) & go right for the meat (to get an idea of how great the book is). Read this chapter[^] (be aware this will open the PDF in your browser) & I believe you'll be convinced how great the book is too.

And Now For the Weird & Wonderful
While examining the common_threads.h file for the 3rd example I stumbled upon these lines:
#ifdef __linux__
#include <semaphore.h>
#endif


I always wonder about strange things like that and in this case I thought, "Where is the __linux__ defined?"

I looked it up and discovered Gnu docs for the C PreCompiler (cpp exe)[^].

I tried the command they suggested:
$ cpp -dM


But when I did I could see that cpp was running but just had an empty string.

You actually have to point it at an exe and it'll pull out all the preprocessor commands. What!?!

$ cpp -dM ./threadx


When I ran that I saw a huge list of PreProcess commands. Huge!

I then ran it thru grep like this:
$ cpp -dM ./iox | grep -i linux


I saw the following!!
C++
#define __linux 1
#define __gnu_linux__ 1
#define linux 1
#define __linux__ 1


So, I can see that over the years the convention to determine which OS the compiler is running on has changed. WTF | :WTF:

Wow, things get messy as time goes on, don't they.

BONUS
Here's my favorite pre-processor define I found in the list. Roll eyes | :rolleyes:

C++
#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128

GeneralRe: Linux C PreProcessor: Who Knew? Pin
trønderen4-Jul-24 8:22
trønderen4-Jul-24 8:22 
GeneralRe: Linux C PreProcessor: Who Knew? Pin
Jalapeno Bob4-Jul-24 9:46
professionalJalapeno Bob4-Jul-24 9:46 
GeneralRe: Linux C PreProcessor: Who Knew? Pin
raddevus4-Jul-24 10:14
mvaraddevus4-Jul-24 10:14 
GeneralRe: Linux C PreProcessor: Who Knew? Pin
Dave Kreskowiak4-Jul-24 9:37
mveDave Kreskowiak4-Jul-24 9:37 
GeneralRe: Linux C PreProcessor: Who Knew? Pin
raddevus4-Jul-24 10:16
mvaraddevus4-Jul-24 10:16 
GeneralRe: Linux C PreProcessor: Who Knew? Pin
k50549-Jul-24 3:51
mvek50549-Jul-24 3:51 
GeneralRe: Linux C PreProcessor: Who Knew? Pin
raddevus9-Jul-24 4:51
mvaraddevus9-Jul-24 4:51 
GeneralDoes this scare anyone else? Pin
honey the codewitch4-Jul-24 0:44
mvahoney the codewitch4-Jul-24 0:44 
GeneralRe: Does this scare anyone else? Pin
Peter_in_27804-Jul-24 11:33
professionalPeter_in_27804-Jul-24 11:33 
GeneralRe: Does this scare anyone else? Pin
honey the codewitch4-Jul-24 11:35
mvahoney the codewitch4-Jul-24 11:35 
GeneralWhat the hell GCC, again Pin
k50542-Jul-24 11:32
mvek50542-Jul-24 11:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.