Re: OT: Programming in C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bill Davidsen wrote:

Quiz for next Friday. What are these and what's the difference between them:

int     (*(**p)[])(int)
declare p as pointer to pointer to array of pointer to function (int) returning int

and
int     *(*(**p)[])(int)
declare p as pointer to pointer to array of pointer to function (int) returning pointer to int

I would really want to see both a justification of method and certificate of sanity to someone who actually used either. I can just barely justify pointer to array of function returning int (state machines), these look like something a compiler compiler would do.

I sort of recall using a pointer to an array of structs as the basic data type for anything significant in C but I've mostly forgotten why. I think sometimes it had to do with getting usable semantics to access things in shared memory segments.

Pointer to struct is the heart of good linked lists, and a pointer to array of struct is certainly a reasonably use. I certainly use arrays of pointers to functions, both for state machines and and emulators, after that it gets very hard to maintain.

But even if you only need the pointer to function (at first), you can can put it inside a struct and write all the surrounding code to deal with pointers to arrays of struct (even if there is only one...). I don't think there is any real overhead to doing this and if you start that way you can add elements to the struct when/if you realize you need them without changing the outer loops that handle the pointers or the memory allocation to store them.

--
 Les Mikesell
   lesmikesell@xxxxxxxxx

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux