Click here to Skip to main content
12,078,090 members (47,854 online)

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.

 
AnswerRe: Which code you suggest? Pin
BobJanova29-Jul-13 1:50
memberBobJanova29-Jul-13 1:50 
AnswerRe: Which code you suggest? Pin
irneb29-Jul-13 4:30
memberirneb29-Jul-13 4:30 
GeneralRe: Which code you suggest? Pin
jibalt20-Aug-13 0:31
memberjibalt20-Aug-13 0:31 
AnswerRe: Which code you suggest? Pin
Jonathan C Dickinson29-Jul-13 23:07
memberJonathan C Dickinson29-Jul-13 23:07 
GeneralRe: Which code you suggest? Pin
jibalt20-Aug-13 0:34
memberjibalt20-Aug-13 0:34 
AnswerRe: Which code you suggest? Pin
PIEBALDconsult30-Jul-13 6:24
professionalPIEBALDconsult30-Jul-13 6:24 
AnswerRe: Which code you suggest? Pin
Member 467320230-Jul-13 7:48
memberMember 467320230-Jul-13 7:48 
GeneralRe: Which code you suggest? Pin
johannesnestler1-Aug-13 5:27
memberjohannesnestler1-Aug-13 5:27 
GeneralRe: Which code you suggest? Pin
Member 46732021-Aug-13 6:44
memberMember 46732021-Aug-13 6:44 
GeneralRe: Which code you suggest? Pin
johannesnestler2-Aug-13 0:26
memberjohannesnestler2-Aug-13 0:26 
AnswerRe: Which code you suggest? Pin
ahmed zahmed30-Jul-13 11:18
memberahmed zahmed30-Jul-13 11:18 
AnswerRe: Which code you suggest? Pin
johannesnestler1-Aug-13 5:04
memberjohannesnestler1-Aug-13 5:04 
AnswerRe: Which code you suggest? Pin
Vasudevan Deepak Kumar2-Aug-13 9:29
memberVasudevan Deepak Kumar2-Aug-13 9:29 
GeneralMisaligned elephants Pin
Matthew Faithfull22-Jul-13 3:10
professionalMatthew Faithfull22-Jul-13 3:10 
If have a class containing this snippet declared in a C++ header file.
protected:
 
    _tChar* m_p;
 
    //--------------------------------------------------------------------------------
    struct sHeader
    {
        unsigned short usAlloc;
        unsigned short usLen;
    };
 
    //--------------------------------------------------------------------------------
    struct sFooter
    {
        unsigned short usRefCount;
    };
 
    //--------------------------------------------------------------------------------
    virtual unsigned short HeaderByteSize( void ) const
    {
        return sizeof( sHeader );
    }

The header is used by half a dozen Dlls which are all part of a project. Instances of the class are created and passed around freely except it doesn't work.

Because one dll has decided that sizeof( sHeader ) is 4 bytes as expected and another has decided that it's 16. The same header file, same build options and everything built together in a clean build.

Mad | :mad: Mad | :mad:

The whole point of using sizeof( sHeader ) in the first place instead of just 4 was so that alignment wouldn't screw thing up.

Mad | :mad: Mad | :mad: Mad | :mad:

Now what do I do?
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)

GeneralRe: Misaligned elephants Pin
Richard Deeming22-Jul-13 12:34
professionalRichard Deeming22-Jul-13 12:34 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull22-Jul-13 12:54
professionalMatthew Faithfull22-Jul-13 12:54 
GeneralRe: Misaligned elephants Pin
ExcellentOrg22-Jul-13 22:25
groupExcellentOrg22-Jul-13 22:25 
GeneralRe: Misaligned elephants Pin
enhzflep23-Jul-13 20:51
memberenhzflep23-Jul-13 20:51 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull24-Jul-13 0:03
professionalMatthew Faithfull24-Jul-13 0:03 
GeneralRe: Misaligned elephants Pin
enhzflep24-Jul-13 0:39
memberenhzflep24-Jul-13 0:39 
GeneralRe: Misaligned elephants Pin
Sentenryu24-Jul-13 1:38
memberSentenryu24-Jul-13 1:38 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull24-Jul-13 1:55
professionalMatthew Faithfull24-Jul-13 1:55 
GeneralRe: Misaligned elephants Pin
Sentenryu24-Jul-13 2:18
memberSentenryu24-Jul-13 2:18 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull24-Jul-13 2:23
professionalMatthew Faithfull24-Jul-13 2:23 
GeneralRe: Misaligned elephants Pin
RafagaX24-Jul-13 5:41
memberRafagaX24-Jul-13 5:41 
GeneralRe: Misaligned elephants Pin
Sentenryu24-Jul-13 7:08
memberSentenryu24-Jul-13 7:08 
GeneralRe: Misaligned elephants Pin
BiggerDon24-Jul-13 3:15
memberBiggerDon24-Jul-13 3:15 
GeneralRe: Misaligned elephants Pin
Gary Wheeler24-Jul-13 1:13
memberGary Wheeler24-Jul-13 1:13 
GeneralRe: Misaligned elephants Pin
YvesDaoust23-Jul-13 23:51
memberYvesDaoust23-Jul-13 23:51 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull24-Jul-13 0:10
professionalMatthew Faithfull24-Jul-13 0:10 
GeneralRe: Misaligned elephants Pin
Ralph Little24-Jul-13 7:32
memberRalph Little24-Jul-13 7:32 
GeneralRe: Misaligned elephants Pin
Member 460889824-Jul-13 11:02
memberMember 460889824-Jul-13 11:02 
GeneralRe: Misaligned elephants Pin
SortaCore24-Jul-13 1:04
memberSortaCore24-Jul-13 1:04 
GeneralRe: Misaligned elephants Pin
rbocquier24-Jul-13 1:39
memberrbocquier24-Jul-13 1:39 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull24-Jul-13 1:53
professionalMatthew Faithfull24-Jul-13 1:53 
GeneralRe: Misaligned elephants Pin
Stuart Dootson24-Jul-13 6:18
memberStuart Dootson24-Jul-13 6:18 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull24-Jul-13 6:24
professionalMatthew Faithfull24-Jul-13 6:24 
GeneralRe: Misaligned elephants Pin
jschell24-Jul-13 10:26
memberjschell24-Jul-13 10:26 
GeneralMessage Automatically Removed Pin
Brisingr Aerowing19-Jul-13 7:46
professionalBrisingr Aerowing19-Jul-13 7:46 
GeneralRe: Extension Methods Pin
Andrew Rissing19-Jul-13 8:06
memberAndrew Rissing19-Jul-13 8:06 
GeneralRe: Extension Methods Pin
Richard Deeming19-Jul-13 8:20
professionalRichard Deeming19-Jul-13 8:20 
GeneralRe: Extension Methods Pin
Gary Wheeler19-Jul-13 8:21
memberGary Wheeler19-Jul-13 8:21 
GeneralRe: Extension Methods Pin
TnTinMn19-Jul-13 9:00
memberTnTinMn19-Jul-13 9:00 
GeneralRe: Extension Methods Pin
Jacek Gajek19-Jul-13 9:08
memberJacek Gajek19-Jul-13 9:08 
GeneralRe: Extension Methods Pin
Richard Deeming19-Jul-13 9:55
professionalRichard Deeming19-Jul-13 9:55 
GeneralRe: Extension Methods Pin
Jacek Gajek19-Jul-13 10:06
memberJacek Gajek19-Jul-13 10:06 
GeneralRe: Extension Methods Pin
PIEBALDconsult19-Jul-13 9:09
professionalPIEBALDconsult19-Jul-13 9:09 
GeneralRe: Message Automatically Removed Pin
lewax0019-Jul-13 10:35
memberlewax0019-Jul-13 10:35 
GeneralRe: Message Automatically Removed Pin
ryanb3119-Jul-13 11:22
memberryanb3119-Jul-13 11:22 
GeneralRe: Message Automatically Removed Pin
lewax0021-Jul-13 12:03
memberlewax0021-Jul-13 12:03 

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.


Advertise | Privacy | Mobile
Web02 | 2.8.160212.1 | Last Updated 13 Feb 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid