Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Need help in understanding C++ code

Reply
Thread Tools

Need help in understanding C++ code

 
 
William.Joseph.Batson@gmail.com
Guest
Posts: n/a
 
      03-15-2007
Hi,

I found the following c++ code, but I need help in understand what it
is trying to do:
if the caller does this
DPRINTF(D_MINI_FS, ("CHXMiniFileSystem()\n"));

what will happen according to the following macro?


extern void dprintf( const char *, ... )
#ifdef __GNUC__
__attribute__((format(printf,1,2)))
#endif /* __GNUC__ */
;
extern void dprintfx( const char *, ... )
#ifdef __GNUC__
__attribute__((format(printf,1,2)))
#endif /* __GNUC__ */
;

#ifdef DEVEL_DEBUG
#define DPRINTF(mask,x) if (debug_level() & (mask)) { \
dprintf("%s:%d ", __FILE__, __LINE__); dprintfx x; } else
#else
#define DPRINTF(mask,x) if (debug_level() & (mask)) dprintf x; else
#endif /* DEVEL_DEBUG */

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      03-15-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi,
>
> I found the following c++ code, but I need help in understand what it
> is trying to do:
> if the caller does this
> DPRINTF(D_MINI_FS, ("CHXMiniFileSystem()\n"));
>
> what will happen according to the following macro?
>
>
> extern void dprintf( const char *, ... )
> #ifdef __GNUC__
> __attribute__((format(printf,1,2)))
> #endif /* __GNUC__ */
> ;
> extern void dprintfx( const char *, ... )
> #ifdef __GNUC__
> __attribute__((format(printf,1,2)))
> #endif /* __GNUC__ */
> ;
>
> #ifdef DEVEL_DEBUG
> #define DPRINTF(mask,x) if (debug_level() & (mask)) { \
> dprintf("%s:%d ", __FILE__, __LINE__); dprintfx x; } else
> #else
> #define DPRINTF(mask,x) if (debug_level() & (mask)) dprintf x; else
> #endif /* DEVEL_DEBUG */


Put it in a file, compile it while retaining preprocessor output
and you will see. To rephrase, a compilation result on your machine
is worth a thousand newsgroup posts with explanations.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      03-15-2007
William.Joseph.Batson wrote:

> I found the following c++ code, but I need help in understand what it
> is trying to do:


This is C code. Even if a C++ compiler could compile it, if it _could_
compile with a C compiler, then we better call it C.

> if the caller does this
> DPRINTF(D_MINI_FS, ("CHXMiniFileSystem()\n"));
>
> what will happen according to the following macro?


Roughly, if debugging is turned on for this system, it will print the file
name, line number, and an arbitrary number of arguments, as a printf()
string.

If your compiler is not GNU C, the system gives up and doesn't print the
arbitrary set of arguments, because the system uses format() and does not
expect it to exist on other systems.

Note that most of the stuff here is non-Standard, meaning questions about it
will get the best answer on a GNU C forum.

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(newbie) need help understanding a few lines of code Ben Perl Misc 6 04-15-2009 11:23 PM
Need help in understanding a python code silverburgh.meryl@gmail.com Python 15 11-18-2008 12:20 AM
need help with understanding this little bit of code Daniel ASP .Net 8 09-13-2007 07:16 PM
Need help in understanding c code Herman.Schultz@gmail.com C Programming 2 06-02-2007 12:38 AM
need help understanding this code. Elmbrook Javascript 7 09-28-2003 11:11 PM



Advertisments