Click here to Skip to main content
15,881,204 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.

 
GeneralRe: This is actually cleaned up! Pin
honey the codewitch15-Dec-21 9:17
mvahoney the codewitch15-Dec-21 9:17 
GeneralRe: This is actually cleaned up! Pin
Rick York15-Dec-21 6:30
mveRick York15-Dec-21 6:30 
GeneralRe: This is actually cleaned up! Pin
honey the codewitch15-Dec-21 6:38
mvahoney the codewitch15-Dec-21 6:38 
GeneralRe: This is actually cleaned up! Pin
Rick York15-Dec-21 6:55
mveRick York15-Dec-21 6:55 
GeneralRe: This is actually cleaned up! Pin
honey the codewitch15-Dec-21 6:58
mvahoney the codewitch15-Dec-21 6:58 
GeneralRe: This is actually cleaned up! Pin
jschell23-Jan-22 8:54
jschell23-Jan-22 8:54 
GeneralRe: This is actually cleaned up! Pin
honey the codewitch24-Jan-22 1:00
mvahoney the codewitch24-Jan-22 1:00 
GeneralRe: This is actually cleaned up! Pin
jschell30-Jan-22 6:13
jschell30-Jan-22 6:13 
honey the codewitch wrote:
so I'm confused as to how you could say it was more maintainable having never seen it.


A specific code sample was presented in a comment. Then you said.

"The reason that I wouldn't do what you're doing is I am a stickler about namespace polution."

You statement strongly suggested that you were responding to the code sample.
I did of course see the code sample in the posted response and then I responded to your comment about that code sample.


honey the codewitch wrote:
Furthermore, it is not feasible to limit said preprocessor macros to a single file as doing so would increase maintenance since several processors with their own instructions are presented, each in its own header. To combine them would create a monolithic header that included every single build target. No.


No idea what you are talking about.

If you have one and exactly one C or C++ file (a .c or .cpp file) then you can define macros at the top of that file. The scope of those macros, in both languages are limited exclusively to that file. That is how those languages work.

If you have several files that use the same code then you can put the macro(s) and only those macros in an h file and then use that h file only in those code files. That means specifically that you do not put it in some other h file for convenience.

Now if you have the code snippet (not the macros) in an h file, then I suggest moving it out of the h file because it should not be in there in the first place.


honey the codewitch wrote:
Finally, unit testing this is not feasible, as I don't have the money to set up the hardware array necessary to unit test this across all build targets


Huh?

A "unit test" in the context my statement would never be tested in that fashion. You are testing the macro not the system.
GeneralRe: This is actually cleaned up! Pin
honey the codewitch30-Jan-22 9:02
mvahoney the codewitch30-Jan-22 9:02 
GeneralRe: This is actually cleaned up! Pin
jschell17-Feb-22 10:33
jschell17-Feb-22 10:33 
JokeRe: This is actually cleaned up! Pin
Nelek15-Dec-21 10:59
protectorNelek15-Dec-21 10:59 
GeneralRe: This is actually cleaned up! Pin
Fueled By Decaff15-Dec-21 6:30
Fueled By Decaff15-Dec-21 6:30 
GeneralRe: This is actually cleaned up! Pin
honey the codewitch15-Dec-21 6:32
mvahoney the codewitch15-Dec-21 6:32 
GeneralRe: This is actually cleaned up! Pin
Al_Brown31-Dec-21 1:44
Al_Brown31-Dec-21 1:44 
GeneralRe: This is actually cleaned up! Pin
honey the codewitch31-Dec-21 3:14
mvahoney the codewitch31-Dec-21 3:14 
GeneralRe: This is actually cleaned up! Pin
Al_Brown31-Dec-21 4:38
Al_Brown31-Dec-21 4:38 
GeneralMessage Closed Pin
13-Dec-21 14:55
mvahoney the codewitch13-Dec-21 14:55 
GeneralRe: IME, It's a lot harder to shop for people when they get pregnant Pin
Brisingr Aerowing13-Dec-21 15:01
professionalBrisingr Aerowing13-Dec-21 15:01 
GeneralRe: IME, It's a lot harder to shop for people when they get pregnant Pin
honey the codewitch13-Dec-21 15:06
mvahoney the codewitch13-Dec-21 15:06 
GeneralI'm not sure how I feel about Forth implemented on a Cortex M-0 Pin
honey the codewitch13-Dec-21 0:09
mvahoney the codewitch13-Dec-21 0:09 
GeneralRe: I'm not sure how I feel about Forth implemented on a Cortex M-0 Pin
trønderen13-Dec-21 16:55
trønderen13-Dec-21 16:55 
GeneralRe: I'm not sure how I feel about Forth implemented on a Cortex M-0 Pin
Richard Deeming13-Dec-21 21:58
mveRichard Deeming13-Dec-21 21:58 
JokeRe: I'm not sure how I feel about Forth implemented on a Cortex M-0 Pin
englebart1-Sep-22 15:12
professionalenglebart1-Sep-22 15:12 
GeneralRe: I'm not sure how I feel about Forth implemented on a Cortex M-0 Pin
Rick York14-Dec-21 19:45
mveRick York14-Dec-21 19:45 
GeneralRe: I'm not sure how I feel about Forth implemented on a Cortex M-0 Pin
Gary Wheeler31-Dec-21 4:07
Gary Wheeler31-Dec-21 4:07 

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.