[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] [C] debug udprint funktion ala printf



On Sun, 23 Nov 2003 12:06:35 +0100
Kim Schulz <sslug@sslug> wrote:

> > #ifdef DEBUG
> > #define dprintf printf
> > #endif
> > 
> > Ikke compiletestet. Kan vist goeres mere robust ved at skrive
> 
> den virker men jeg får en warning når den er slået fra:
> gui.c:180: warning: implicit declaration of function `dprintf'

Jaja og du vil heller ikke kunne linke. Så hvis jeg må citere mig selv.



int nullprintf(const char * format, ...) { return 0 ; }

#if defined DBGP
#define debugp printf
#else
#define debugp nullprintf
#endif

Det er noget i den stil, som Rasmus Andersen foreslår. Der er to
problemer, eller svagheder, 

  1. du kommer til at betale med et functioncall når du ikke debugger.

  2. du bruger preprocessoren, hvilket af mange årsager er knap så heldigt.

Så her kommer GCC med inline handy ind

inline int nullprintf(const char * format, ...) { return 0 ; }

vil erstatte debugp med et statement 0;

Det ER testet!!!


-- 
sslug@sslug -- http://d-axel.dk/


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:10 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *