⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 funcargs.c

📁 gdb-6.8 Linux下的调试程序 最新版本
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  Test passing of arguments to functions.  Use various sorts of arguments,    including basic types, pointers to those types, structures, lots of    args, etc, in various combinations. *//* AIX requires this to be the first thing in the file.  */#ifdef __GNUC__#  define alloca __builtin_alloca#  define HAVE_STACK_ALLOCA 1#else /* not __GNUC__ */#  ifdef _AIX     #pragma alloca#    define HAVE_STACK_ALLOCA 1#  else /* Not AIX */#    ifdef sparc#      include <alloca.h>#      define HAVE_STACK_ALLOCA 1#      ifdef __STDC__         void *alloca ();#      else         char *alloca ();#      endif /* __STDC__ */#    endif /* sparc */#  endif /* Not AIX */#endif /* not __GNUC__ */char c = 'a';char *cp = &c;unsigned char uc = 'b';unsigned char *ucp = &uc;short s = 1;short *sp = &s;unsigned short us = 6;unsigned short *usp = &us;int i = 2;int *ip = &i;unsigned int ui = 7;unsigned int *uip = &ui;long l = 3;long *lp = &l;unsigned long ul = 8;unsigned long *ulp = &ul;float f = 4.0;float *fp = &f;double d = 5.0;double *dp = &d;struct stag {    int s1;    int s2;} st = { 101, 102 };struct stag *stp = &st;union utag {    int u1;    long u2;} un;union utag *unp = &un;char carray[] = {'a', 'n', ' ', 'a', 'r', 'r', 'a', 'y', '\0'};/* Test various permutations and interleaving of integral arguments */#ifdef PROTOTYPESvoid call0a (char c, short s, int i, long l)#elsecall0a (c, s, i, l)char c; short s; int i; long l;#endif{  c = 'a';  s = 5;  i = 6;  l = 7;}#ifdef PROTOTYPESvoid call0b (short s, int i, long l, char c)#elsecall0b (s, i, l, c)short s; int i; long l; char c;#endif{  s = 6; i = 7; l = 8; c = 'j';}#ifdef PROTOTYPESvoid call0c (int i, long l, char c, short s)#elsecall0c (i, l, c, s)int i; long l; char c; short s;#endif{  i = 3; l = 4; c = 'k'; s = 5;}#ifdef PROTOTYPESvoid call0d (long l, char c, short s, int i)#elsecall0d (l, c, s, i)long l; char c; short s; int i;#endif{  l = 7; c = 'z'; s = 8; i = 9;}#ifdef PROTOTYPESvoid call0e (char c1, long l, char c2, int i, char c3, short s, char c4, char c5)#elsecall0e (c1, l, c2, i, c3, s, c4, c5)char c1; long l; char c2; int i; char c3; short s; char c4; char c5;#endif{  c1 = 'a'; l = 5; c2 = 'b'; i = 7; c3 = 'c'; s = 7; c4 = 'f'; c5 = 'g';}/* Test various permutations and interleaving of unsigned integral arguments */#ifdef PROTOTYPESvoid call1a (unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)#elsecall1a (uc, us, ui, ul)unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;#endif{  uc = 5; us = 6; ui = 7; ul = 8;}#ifdef PROTOTYPESvoid call1b (unsigned short us, unsigned int ui, unsigned long ul, unsigned char uc)#elsecall1b (us, ui, ul, uc)unsigned short us; unsigned int ui; unsigned long ul; unsigned char uc;#endif{  uc = 5; us = 6; ui = 7; ul = 8;}#ifdef PROTOTYPESvoid call1c (unsigned int ui, unsigned long ul, unsigned char uc, unsigned short us)#elsecall1c (ui, ul, uc, us)unsigned int ui; unsigned long ul; unsigned char uc; unsigned short us;#endif{  uc = 5; us = 6; ui = 7; ul = 8;}#ifdef PROTOTYPESvoid call1d (unsigned long ul, unsigned char uc, unsigned short us, unsigned int ui)#elsecall1d (ul, uc, us, ui)unsigned long ul; unsigned char uc; unsigned short us; unsigned int ui;#endif{  uc = 5; us = 6; ui = 7; ul = 8;}#ifdef PROTOTYPESvoid call1e (unsigned char uc1, unsigned long ul, unsigned char uc2, unsigned int ui, unsigned char uc3, unsigned short us, unsigned char uc4, unsigned char uc5)#elsecall1e (uc1, ul, uc2, ui, uc3, us, uc4, uc5)unsigned char uc1; unsigned long ul; unsigned char uc2; unsigned int ui;unsigned char uc3; unsigned short us; unsigned char uc4; unsigned char uc5;#endif{  uc1 = 5; ul = 7; uc2 = 8; ui = 9; uc3 = 10; us = 11; uc4 = 12; uc5 = 55;}/* Test various permutations and interleaving of integral arguments with   floating point arguments. */#ifdef PROTOTYPESvoid call2a (char c, float f1, short s, double d1, int i, float f2, long l, double d2)#elsecall2a (c, f1, s, d1, i, f2, l, d2)char c; float f1; short s; double d1; int i; float f2; long l; double d2;#endif{  c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;}#ifdef PROTOTYPESvoid call2b (float f1, short s, double d1, int i, float f2, long l, double d2, char c)#elsecall2b (f1, s, d1, i, f2, l, d2, c)float f1; short s; double d1; int i; float f2; long l; double d2; char c;#endif{  c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;}#ifdef PROTOTYPESvoid call2c (short s, double d1, int i, float f2, long l, double d2, char c, float f1)#elsecall2c (s, d1, i, f2, l, d2, c, f1)short s; double d1; int i; float f2; long l; double d2; char c; float f1;#endif{  c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;}#ifdef PROTOTYPESvoid call2d (double d1, int i, float f2, long l, double d2, char c, float f1, short s)#elsecall2d (d1, i, f2, l, d2, c, f1, s)double d1; int i; float f2; long l; double d2; char c; float f1; short s;#endif{  c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;}#ifdef PROTOTYPESvoid call2e (int i, float f2, long l, double d2, char c, float f1, short s, double d1)#elsecall2e (i, f2, l, d2, c, f1, s, d1)int i; float f2; long l; double d2; char c; float f1; short s; double d1;#endif{  c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;}#ifdef PROTOTYPESvoid call2f (float f2, long l, double d2, char c, float f1, short s, double d1, int i)#elsecall2f (f2, l, d2, c, f1, s, d1, i)float f2; long l; double d2; char c; float f1; short s; double d1; int i;#endif{  c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;}#ifdef PROTOTYPESvoid call2g (long l, double d2, char c, float f1, short s, double d1, int i, float f2)#elsecall2g (l, d2, c, f1, s, d1, i, f2)long l; double d2; char c; float f1; short s; double d1; int i; float f2;#endif{  c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;}#ifdef PROTOTYPESvoid call2h (double d2, char c, float f1, short s, double d1, int i, float f2, long l)#elsecall2h (d2, c, f1, s, d1, i, f2, l)double d2; char c; float f1; short s; double d1; int i; float f2; long l;#endif{  c = 'a'; f1 = 0.0; s = 5; d1 = 0.0; i = 6; f2 = 0.1; l = 7; d2 = 0.2;}#ifdef PROTOTYPESvoid call2i (char c1, float f1, char c2, char c3, double d1, char c4, char c5, char c6, float f2, short s, char c7, double d2)#elsecall2i (c1, f1, c2, c3, d1, c4, c5, c6, f2, s, c7, d2)char c1; float f1; char c2; char c3; double d1; char c4; char c5; char c6;float f2; short s; char c7; double d2;#endif{  c1 = 'a'; f1 = 0.0; c2 = 5; d1 = 0.0; c3 = 6; f2 = 0.1; c4 = 7; d2 = 0.2;  c5 = 's'; c6 = 'f'; c7 = 'z'; s = 77;}/* Test pointers to various integral and floating types. */#ifdef PROTOTYPESvoid call3a (char *cp, short *sp, int *ip, long *lp)#elsecall3a (cp, sp, ip, lp)char *cp; short *sp; int *ip; long *lp;#endif{  cp = 0; sp = 0; ip = 0; lp = 0;}#ifdef PROTOTYPESvoid call3b (unsigned char *ucp, unsigned short *usp, unsigned int *uip, unsigned long *ulp)#elsecall3b (ucp, usp, uip, ulp)unsigned char *ucp; unsigned short *usp; unsigned int *uip;unsigned long *ulp;#endif{  ucp = 0; usp = 0; uip = 0; ulp = 0;}#ifdef PROTOTYPESvoid call3c (float *fp, double *dp)#elsecall3c (fp, dp)float *fp; double *dp;#endif{  fp = 0; dp = 0;}/* Test passing structures and unions by reference. */#ifdef PROTOTYPESvoid call4a (struct stag *stp)#elsecall4a (stp)struct stag *stp;#endif{stp = 0;}#ifdef PROTOTYPESvoid call4b (union utag *unp)#elsecall4b (unp)union utag *unp;#endif{  unp = 0;}/* Test passing structures and unions by value. */#ifdef PROTOTYPESvoid call5a (struct stag st)#elsecall5a (st)struct stag st;#endif{st.s1 = 5;}#ifdef PROTOTYPESvoid call5b (union utag un)#elsecall5b (un)union utag un;#endif{un.u1 = 7;}/* Test shuffling of args */void call6k (){}#ifdef PROTOTYPESvoid call6j (unsigned long ul)#elsecall6j (ul)unsigned long ul;#endif{  ul = ul;    call6k ();}#ifdef PROTOTYPESvoid call6i (unsigned int ui, unsigned long ul)#elsecall6i (ui, ul)unsigned int ui; unsigned long ul;#endif{  ui = ui;    call6j (ul);}#ifdef PROTOTYPESvoid call6h (unsigned short us, unsigned int ui, unsigned long ul)#elsecall6h (us, ui, ul)unsigned short us; unsigned int ui; unsigned long ul;#endif{  us = us;    call6i (ui, ul);}#ifdef PROTOTYPESvoid call6g (unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -