复杂c语言程序,帮你解析复杂的C语言声明

很多C/C++的初学者,常常被一些复杂的声明语句弄得晕头转向,满头雾水。比如说:char *(*(*a[])())(),这个声明是什么意思呢?

不用抓耳挠腮,在linux环境下,有一个工具能帮我们解析,它就是cdecl 。它能在C/C++声明和英语间转换。让我们先看看man cdecl里的描述吧:

DESCRIPTION

Cdecl  (and c++decl) is a program for encoding and decoding C (or C++) type declarations.  The C language is based on the (draft proposed) X3J11 ANSI Standard; optionally, the C language may be based on the pre- ANSI  definition  defined  by  Kernighan  &  Ritchie’s The C Programming Language book, or the C language  defined by the Ritchie PDP-11 C compiler.  The C++ language is based on Bjarne Stroustrup’s The C++  Pro-gramming Language, plus the version 2.0 additions to the language.

很容易用:键入cdecl命令,进入交互界面:

# cdecl

Type `help' or `?' for help

cdecl>

这时键入命令:

explain char *(*(*a[])())()

看看输出什么了:

declare a as array of pointer to function returning pointer to function returning pointer to char

cdecl>

反过来,我们把输出的英文当命令,再执行一次看看:

cdecl> declare a as array of pointer to function returning pointer to function returning pointer to char

char *(*(*a[])())()

cdecl>

好用吧,如果有不明白,就help一下。

2010-12-28 于 杭州

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值