Click here to Skip to main content
15,908,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Accessing Excel Cells from Visual C++ Pin
Richard Ellis30-Jan-02 12:14
Richard Ellis30-Jan-02 12:14 
GeneralRe: Accessing Excel Cells from Visual C++ Pin
wangyiming30-Jan-02 14:33
wangyiming30-Jan-02 14:33 
QuestionBad Coding? Pin
James R. Twine30-Jan-02 6:42
James R. Twine30-Jan-02 6:42 
AnswerRe: Bad Coding? Pin
Roger Allen30-Jan-02 6:56
Roger Allen30-Jan-02 6:56 
GeneralRe: Bad Coding? Pin
James R. Twine30-Jan-02 7:04
James R. Twine30-Jan-02 7:04 
AnswerRe: Bad Coding? Pin
Igor Proskuriakov30-Jan-02 7:15
Igor Proskuriakov30-Jan-02 7:15 
GeneralRe: Bad Coding? Pin
James R. Twine30-Jan-02 8:48
James R. Twine30-Jan-02 8:48 
AnswerRe: Bad Coding? Pin
Chris Losinger30-Jan-02 9:02
professionalChris Losinger30-Jan-02 9:02 
I agree, that's some bad coding.

Here's some questionable coding i found in a widely used TIFF reading library

#define	REPEAT8(op)	REPEAT4(op); REPEAT4(op)
#define	REPEAT4(op)	REPEAT2(op); REPEAT2(op)
#define	REPEAT2(op)	op; op

#define	CASE8(x,op)			\
   switch (x) {			\
    case 7: op; case 6: op; case 5: op;	\
    case 4: op; case 3: op; case 2: op;	\
    case 1: op;				\
}

#define	UNROLL8(w, op1, op2) {		\
   uint32 _x;				\
   for (_x = w; _x >= 8; _x -= 8) {	\
   op1;				\
   REPEAT8(op2);			\
   }					\
   if (_x > 0) {			\
   op1;				\
   CASE8(_x,op2);			\
   }					\
}

// then, later on in the code:

   while (h-- > 0) {
      uint32* bw;
      UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++);
      cp += toskew;
      pp += fromskew;
   }


not only is this totally wierd, it is also a complete pain in the ass to debug (cause you can't step into a macro). those UNROLL8 things get expanded into loops of switch statements which are actually unrolled loops themselves, or into repetitions of statements. aahhhHH!!! i had to unroll this code to use it in another app. i almost went crazy.

this really crunches a lot of code into a few terse macros. but holy crap.. it's impossible to understand.

-c



Smaller Animals Software, Inc.

AnswerRe: Bad Coding? Pin
Joaquín M López Muñoz30-Jan-02 9:08
Joaquín M López Muñoz30-Jan-02 9:08 
GeneralChange the date of file! Pin
Mazdak30-Jan-02 6:14
Mazdak30-Jan-02 6:14 
GeneralRe: Change the date of file! Pin
Ravi Bhavnani30-Jan-02 6:24
professionalRavi Bhavnani30-Jan-02 6:24 
Generalstring usage problem Pin
30-Jan-02 6:00
suss30-Jan-02 6:00 
GeneralRe: string usage problem Pin
Joaquín M López Muñoz30-Jan-02 7:51
Joaquín M López Muñoz30-Jan-02 7:51 
GeneralC++ Macros in Visual C++ Pin
30-Jan-02 5:18
suss30-Jan-02 5:18 
GeneralRe: C++ Macros in Visual C++ Pin
Bill Wilson30-Jan-02 10:14
Bill Wilson30-Jan-02 10:14 
GeneralForaging for Suggestions Pin
Roger Wright30-Jan-02 5:05
professionalRoger Wright30-Jan-02 5:05 
Generala question about exit() method Pin
Gérald Mercet30-Jan-02 4:59
Gérald Mercet30-Jan-02 4:59 
GeneralRe: a question about exit() method Pin
Ravi Bhavnani30-Jan-02 5:05
professionalRavi Bhavnani30-Jan-02 5:05 
GeneralRe: a question about exit() method Pin
Gérald Mercet30-Jan-02 5:17
Gérald Mercet30-Jan-02 5:17 
Generalloading bitmaps Pin
Rajveer30-Jan-02 4:13
Rajveer30-Jan-02 4:13 
GeneralRe: loading bitmaps Pin
.:: RockNix ::.30-Jan-02 4:12
.:: RockNix ::.30-Jan-02 4:12 
GeneralRe: loading bitmaps Pin
lucy30-Jan-02 6:40
lucy30-Jan-02 6:40 
GeneralRe: loading bitmaps Pin
Michael Dunn30-Jan-02 6:45
sitebuilderMichael Dunn30-Jan-02 6:45 
GeneralVC6 Pin
30-Jan-02 3:01
suss30-Jan-02 3:01 
GeneralRe: VC6 Pin
Rüpel30-Jan-02 3:04
Rüpel30-Jan-02 3:04 

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.