小编Man*_*uel的帖子

C11 _通用用法

我试图学习如何使用"新"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)

c generics macros default c11

6
推荐指数
2
解决办法
2099
查看次数

如何清空列表

我试图找出在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)

但是,我仍然想知道是否有任何方法像第一个函数那样手动完成,但没有任何未使用的变量.

lisp stack common-lisp

0
推荐指数
2
解决办法
92
查看次数

标签 统计

c ×1

c11 ×1

common-lisp ×1

default ×1

generics ×1

lisp ×1

macros ×1

stack ×1