我试图学习如何使用"新"C11通用表达式,但我碰到了一堵墙.
请考虑以下代码:
#include <stdlib.h>
#include <stdio.h>
#define test(X, Y, c) \
_Generic((X), \
double: _Generic((Y), \
double * : test_double, \
default: test_double \
), \
int: _Generic((Y), \
int * : test_int, \
default: test_int \
) \
) (X, Y, c)
int test_double(double a, double *b, int c);
int test_int(int a, int *b, int c);
int test_double(double a, double *b, int c) { return 1; }
int test_int(int a, int *b, int c) { return 2; }
int …Run Code Online (Sandbox Code Playgroud) 我试图找出在Common Lisp中清空列表(看作堆栈)的方法.
我想出了这个:
(defun emptystack ()
(dolist (var *stack*) (pop *stack*)))
Run Code Online (Sandbox Code Playgroud)
但它在编译时生成警告(VAR已定义但从未使用过).
然后我认为这样做会更简单:
(setq *stack* nil)
Run Code Online (Sandbox Code Playgroud)
但是,我仍然想知道是否有任何方法像第一个函数那样手动完成,但没有任何未使用的变量.