看板 DFBSD_kernel 關於我們 聯絡資訊
At 1:58 AM -0500 11/11/04, George Georgalis wrote: > >I have a general idea about the use of pointers, but don't really >understand how they are used. What exactly does this syntax mean? > > struct vnode **vpp, *vp; > vpp = &vp; You may find it helpful to install the port called 'cdecl'. It can help to explain declarations (although it will not help with executable statements, such as the second line). E.g.: (3) cdecl Type `help' or `?' for help - explain struct vnode **vpp; declare vpp as pointer to pointer to struct vnode The "explain" command is what you type in, and the following line is what `cdecl' replied with. `cdecl' does not know everything about the C language, and in particular you can only ask it to explain a single declaration at a time. It will give an error message for: explain struct vnode **vpp, *vp; even though that is completely valid C. So, it is not a magic know-all utility, but it can be helpful if you are new to C. Note that it also helps when going from an english description into a valid C declaration, so you can enter the *command* of: declare vpp as pointer to pointer to struct vnode and `cdecl' will reply with: struct vnode **vpp This helped when I was coming from a systems-programming language called *Plus, which was similar to Pascal/Algol in many ways. -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu