[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tests & shared libraries

Peter Burns wrote:

>I found a few flaws. I get warning messages about the comma operator
>with each use of ppDebug1 in the code if I don't have PP_DEBUGLEVEL >= 4 
>#define ppDebug1 (void) doesn't cut it
>Correct me if I'm wrong but wouldn't that turn 
>ppDebug1("text %s", "more text");
>(void)("text %s", "more text"); 

Right. The problem is that ppDebug1 & Co take a variable argument list.
Experimentally I found that
#define ppDebug1(EXPR,...) 
works here, but that (the ellipse in the Macro definition) seems to be
highly specific to the GNU preprocessor (it isn't mentioned anywhere).

>I can get rid of it by using
>inline void  ppDebug(const char*, ...) {} 
>instead of the define, but I'm not sure that that is a good thing to do.

Std C doesn't know the "inline" keyword, so that's not a viable solution.

Perhaps if we do a

  // as usual
#  ifdef __GNUC__
#    define ppDebug1(EXPR,...)
#  else
#    define ppDebug1 pp_PrintfLikeStub
#  endif

and define in ppUtils.cpp

PP_EXTC void pp_PrintfLikeStub (const char *expr, ...) {}

>I decided to move the tests in PenguinSound to a separate directory
>and use libpenguinplay.so instead of the static library. Doing that I
>found that 
>_ppDebug etc need to have a PP_EXTC prepended to it in ppUtils.cpp

<looking> Correct. Fixing that now

>There is also a bit of a mixup between the VirtWrite prototype and its

Where is VirtWrite declared and what is it for? A grep over
include/PenguinPlay didn't fid it. Same for src/ and its subdirs.

>variable in PenguinFile. The global variable is  FileTGlobalData
>FileGlobalData; and it is defined in FileGlobalData
>a void* . 

void* ?? How do you mean this? In FileGlobalData.cpp a single instance of
FileTGlobalData is created as global (in our namespace) variable.

>FileGlobalData is a singleton. There are better ways to
>implement singletons. Take a look at my RegistryFactory for the way I
>did it.
>Instead of creating a separate global variable give FileTGlobalData a
>method to 
>retrieve an instance of itself. Make the constructor private. Then the
>variable won't be created at startup. It won't be created until it is

Hmmm, I'll look into it. perhaps I can do the changes already today.

>The bad memory access was at  Directory::Misc::GetHashOf.

Ah, right. GetHashOf () counts (from 1 to key.m_nameLen) instead of (from 0
to key.m_nameLen-1). Fixed.


Drive A: not responding...Formatting C: instead