Eliminate all of the console output message

Jan-Benedict Glaw jbglaw at lug-owl.de
Tue Sep 26 13:33:08 UTC 2006


On Tue, 2006-09-26 17:40:42 +0800, colin <colin at realtek.com.tw> wrote:
> I am trying to eliminate all of the console output message of the embedded
> application.
> What I do is like this:
>     #define puts do { } while (0)
> 
> printf and putchar will also be replaced by this way.
> Is it safe to do this?

Consider:

	while (1) {
		printf ("Next element: %d\n", n++);
		if (n == 10)
			break;
	}

So generally, this is not save, because you still need to evaluate the
arguments.

However, in the Linux kernel uses something similar for embedded
systems (linux-2.6.x/include/linux/kernel.h):

150	static inline int printk(const char *s, ...)
151		__attribute__ ((format (printf, 1, 2)));
152	static inline int printk(const char *s, ...) { return 0; }

You can use something similar to still perform argument evaluation
while optimizing out the whole call.  However, if you even miss to
include your header containing this define, the program will still
pull the function at link time.  Also keep in mind that some libraries
will have wrapper macros for these funcions, pointing to actual
differently named functions...

MfG, JBG

-- 
      Jan-Benedict Glaw      jbglaw at lug-owl.de              +49-172-7608481
 Signature of:                      http://perl.plover.com/Questions.html
 the second  :
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20060926/bbaea636/attachment-0002.pgp 


More information about the uClibc mailing list