Kernel Study Notes

Home Archives
2007-06-12
gcc

gcc参数可变的宏定义

#define LOGSTRINGS(fm, ...) printf(fm,__VA_ARGS__)

使用方法
LOGSTRINGS("hello, %d ", 10);

但是必须有第二个参数!否则编译无法通过。

改进
#define LOGSTRINGS(fm, ...) printf(fm, ##__VA_ARGS__)
LOGSTRINGS("hello, world\n");

最简单的方法
#define LOGSTRINGS(...) printf(__VA_ARGS__)

Share
  • gcc
Newer
subst: replace string in Makefile
Older
gcc attribute

Recent Posts

  • linux网口<UP> 和state UP 的区别
  • ECMP Hash 计算详解: fib_multipath_hash() 四种策略全解析
  • Linux 内核 Nexthop 对象化: Patch 4c7e8084 深度解析
  • tcp_v4_connect 三次路由查询详解
  • ECMP选路: fib_select_multipath Hash 机制深度解析

Categories

  • IPv6
  • bpf
  • debug
  • gcc
  • irq
  • memory
  • neighbour
  • netdev
  • netlink
  • others
  • route
  • sched
  • tools
  • xfrm

Tags

  • IPv4
  • IPv6
  • TODO
  • address
  • bh
  • bpf
  • checksum
  • debug
  • epoll
  • fib
  • gcc
  • git
  • ip-link
  • ipv6
  • irq
  • kernel
  • linux
  • memory
  • namespace
  • neighbour
  • netdev
  • netdevice
  • netlink
  • network
  • others
  • ovs
  • route
  • routing
  • sched
  • socket
  • tcp
  • tcpdump
  • vim
  • xdp
  • xfrm
© 2026 Martinbj2008
Powered by Hexo
Home Archives