数组堆栈的宏?????
程序代码:
#include<stdio.h> #include<stdlib.h> #include <assert.h>// 断言 //下面是数组堆栈的宏 函数依次是 判空 判满 压入 置顶 输出 #define generic_stack(stack_type,suffix,stack_size) \ static stack_type stack##suffix[stack_size]; \ static int top_element##suffix=-1; \ int is_empty##suffix() \ { \ return top_element##suffix==-1; \ } \ void is_full##suffix() \ { \ return top_element##suffix==stack_size-1; \ } \ int push##suffix(stack_type value) \ { \ assert(!is_full##suffix()); \ top_element##suffix+=1; \ stack##suffix[top_element##suffix]=value; \ } \ void pop##suffix() \ { \ assert(!is_empty##suffix()); \ top_element##suffix-=1; \ } \ stack_type top##suffix() \ { \ assert(!is_empty##suffix()); \ return stack##suffix[top_element##suffix]; \ } void main() { generic_stack(int,_int,10); push_int(5);//输入5 push_int(10); push_int(20); while(!is_empty_int()) { printf("%d\n",top_int());//输出 pop_int(); } }通不过编译器啊!!!!!!!