#ifdef TEST_IFDEF
printf("Test #ifdef");
#elif TEST_ELIF
printf("Test #elif");
#else
printf("Test #else");
#endif
And after my trying.
It's work well :D
2011/11/04
[C/C++ basic] Preprocessing #ifdef, #elif, #else
2011/09/26
[C/C++]switch-case with range?
//===================
switch (a)
{
case 1 ... 10:
//do somthing
break;
case 11 ... 20:
//do somthing
break;
default:
//do something
break;
}
//===================
This is successfully with gcc compiler.
But not done with VC++
That's because Standard C doesn't support switch-case with range.
I found the answer from http://c-faq.com/misc/nonconstcase.html
If using gcc with option -pedantic,
then will be error occur when compile like below:
warning: range expressions in switch statements are non-standard
unless you are clarify what are you doing, and understand the code portable issue.
DONOT using switch-case with range! (my own suggestion...)
2011/04/19
Using mii-tool/ethtools to sniff status of network interface
# mii-tool -V mii-tool.c 1.9 2000/04/28 00:56:08 (David Hinds) SIOCGMIIPHY on 'eth0' failed: Operation not supported no MII interfaces foundThen I google this problem find out, mii-tool has lot of bug, and some net drivers didn't support it. So, I am trying using ethtool which have more compatibility. And it work great!!
# ethtool eth0 Settings for eth0: Supported ports: [ TP MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: MII PHYAD: 1 Transceiver: internal Auto-negotiation: on Link detected: yesSo, If just want to know about network status, Maybe ethtool is better than mii-tool, But, unfortunately, I still need to resolving mii-tool's problem for our environment. So, If you meet the trouble about "no MII interfaces found", make sure the mii-tool is follow up the newest one release. It would possible make the trouble disappear...or not...OTZ
2011/04/13
Mac OS disable/enable .DS_Store
vbindiff : Good tools for compare binary files.
2011/04/12
SD card automount for Embedded Linux
If we want to using SD card auto mount.
Please reference manual page of command "mdev".
# mdev --helpBusyBox v1.18.4 (2011-04-01 22:32:35 CST) multi-call binary.
Usage: mdev [-s]
-s Scan /sys and populate /dev during system boot
It can be run by kernel as a hotplug helper. To activate it: echo /sbin/mdev > /proc/sys/kernel/hotplugIt uses /etc/mdev.conf with lines[-]DEVNAME UID:GID PERM [>|=PATH] [@|$|*PROG]
Follow above information.
step 1. make sure build the feature "hotplug" to kernel
step 2. edit /etc/mdev.conf like below :
sd.* 0:0 660 */sbin/automount.sh $MDEV
mmc.* 0:0 660 */sbin/automount.sh $MDEV
step 3. add /sbin/automount.sh like below:
step 4. Add command at /etc/rc.d/rc.sysinit
# echo /sbin/mdev > /proc/sys/kernel/hotplug