/*
* Recommended alloc parameters for "small" contexts that are never expected
* to contain much data (for example, a context to contain a query plan).
*/
#define ALLOCSET_SMALL_MINSIZE 0
#define ALLOCSET_SMALL_INITSIZE (1 * 1024)
#define ALLOCSET_SMALL_MAXSIZE (8 * 1024)
#define ALLOCSET_SMALL_SIZES \
ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_SMALL_MAXSIZE
我不明白最后的马可,我用
printf("%d", ALLOCSET_SMALL_SIZES);
然后警告:
warning: too many arguments for format [-Wformat-extra-args]
并且也返回0。
我发现类似的帖子:#define directive with multiple replacements?
更新:跳过源代码,明白了。
类函数
foo(size_t,size_t,size_t)
就可以用
foo(ALLOCSET_DEFAULT_SIZES)
1条答案
按热度按时间lp0sw83n1#
给定以下代码片段:
宏
ALLOCSET_SMALL_SIZES
将替换为:替换为:
它们是独立的参数。然后在对
printf ()
的调用中:ALLOCSET_SMALL_SIZES
被替换为0, (1 * 1024), (8 * 1024)
或者,
所以才有警告。
将其改为:
参见:Why use Macros in C?和What are C macros useful for?