Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.misc > #2224
| From | "Rod Pemberton" <dont_use_email@xnothavet.cqm> |
|---|---|
| Newsgroups | comp.lang.misc |
| Subject | Re: A good subset of C |
| Date | 2014-05-08 07:35 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <op.xfjg4u1y6zenlw@localhost> (permalink) |
| References | (2 earlier) <lk8nrc$ov4$1@dont-email.me> <op.xfesqctt6zenlw@localhost> <lkd3fo$2mv$1@dont-email.me> <op.xfiic4pj6zenlw@localhost> <lkfht2$k2p$1@dont-email.me> |
On Thu, 08 May 2014 05:14:10 -0400, James Harris <james.harris.1@gmail.com> wrote: > "Rod Pemberton" <dont_use_email@xnothavet.cqm> wrote in message > news:op.xfiic4pj6zenlw@localhost... >> James wrote: [added some context back in] >>> Let's take a step back as I didn't clearly explain the point I was >>> making about headers. I was thinking that they normally contain the >>> interface information for a source file. For a source file called >>> source.c the header will normally be called source.h and it will >>> define all of the info that another source file needs in order to >>> interface with functions in source.c. So any program that wants >>> to call services in source.c will #include source.h first. That >>> will tell the compiler the interface info it needs to know. >>> >>> [...] >>> >>> Header files are a poor mechanism because there is no guarantee that >>> the header used when the caller is compiled is the same header that >>> was used when the callee is compiled. But with some discipline they >>> can be effective. >> >> Should a distinction be maded between a program which includes it's >> own header file and a program which includes a C library header file? >> >> In one case, the source which uses those headers are compiled too, >> but not for the other. The other is compiled as a library. > > Sorry, I didn't understand that point. > A header can be used with both the caller and callee to define the interface and provide the interface information, yes? The interface was defined by/for the callee. The code which implements the interfaces is only within the callee. The header is available to both, so that both may call that code. But, there are other situations where headers are used. One is where a program uses it's own header, but nothing else does. If a program defines an interface, that interface isn't shared. So, the header is really exclusive to that code. Should a distinction be made as to how header files are used? >>> I was trying to say that things like struct timespec would need to >>> be communicated to a program that interfaces with time functions. >> >> So, you're planning to object-orient-ize that struct somehow? ;-) > > I see the smiley so know you are kidding but I cannot see the > connection. I wasn't thinking of any object orientation issues here. Ok. That's what I was "asking". I presumed this could be for an object-oriented situation, or possibly similar in nature. I was being humorous in my response but, I perceived converting such a struct to an object-oriented use might be a bit more complicated. >>> Without the header mechanism how could that info be made available >>> to the calling module? >> >> Didn't we have some conversation on something like this at least once >> before, i.e., in reference to passing structs and data over a network? > > If we did that sounds like a dynamic issue. The info in the header such > as a > struct layout is about compile time so is very static! Yes, but it goes to the same or similar nature of the code on one side not "knowing" what the code on the other side provides and not "knowing" how to call the interace and not "knowing" what parameters are required. I.e., I keep getting the impression you're attempting to interface with a "black box". > As an example of a header communicating a structure layout consider > compiling the following reference to a structure > > struct timespec *tp; > tp->tv_nsec = 0; > > That might compile to > > mov [esi + 4], dword 0 > > The point is that to produce this code the offset (4 in this case) > of the field from the pointer needs to be known at compile time. > The header would supply the struct definition from which the compiler > works out the offset. > > I suppose the offset (4) might be filled in a link or load time. > Interesting! > At some point, you need the offset of tv_nsec and the address of the timespec struct, or you need the direct address of tv_nsec. With indirect addressing, you could do something like: ; address timespec + offset tv_nsec mov esi, [address_of_tv_nsec_address] mov eax, [address_of_tv_nsec_offset] lea eax, [esi + eax] mov [eax], dword 0 Or, ; address timespec + offset tv_nsec mov esi, [address_of_tv_nsec_address] mov eax, [address_of_tv_nsec_offset] mov [esi + eax], dword 0 Or, ; address tv_nsec mov eax, [address_of_tv_nsec] mov [eax], dword 0 Here, 'address_of...' are fixed locations in a list or table of all the other needed addresses and offsets. The table/list of needed addresses or offsets are filled in either at compile time or run-time. Rod Pemberton
Back to comp.lang.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 08:47 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 10:56 +0100
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 19:41 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 21:08 +0100
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 21:58 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 22:55 +0100
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-06 00:01 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-06 00:44 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-06 09:45 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-05 07:33 -0400
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 19:14 +0100
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 20:12 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-05 18:57 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-07 11:55 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-07 19:04 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-08 10:14 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-08 07:35 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-08 16:22 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-09 16:45 -0400
Re: A good subset of C "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-10 09:04 +0200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-10 16:30 -0400
Re: A good subset of C "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-11 11:59 +0200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-11 11:06 -0400
Re: A good subset of C Kaz Kylheku <kaz@kylheku.com> - 2014-05-12 00:26 +0000
Re: A good subset of C "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-05-12 09:54 +0200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-12 20:01 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-14 17:45 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-14 18:11 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-14 23:54 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-14 19:43 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-17 18:00 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-17 16:00 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-17 22:17 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-17 19:58 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-18 07:59 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-18 13:10 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-19 00:54 +0100
Re: A good subset of C Andy Walker <news@cuboid.co.uk> - 2014-05-15 01:31 +0100
Re: A good subset of C BGB <cr88192@hotmail.com> - 2014-05-14 23:43 -0500
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-17 18:38 +0100
Re: A good subset of C Ian Collins <ian-news@hotmail.com> - 2014-05-25 11:04 +1200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-24 20:36 -0400
Re: A good subset of C Ian Collins <ian-news@hotmail.com> - 2014-05-25 12:53 +1200
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-24 21:34 -0400
Re: A good subset of C Ian Collins <ian-news@hotmail.com> - 2014-05-25 14:11 +1200
Re: A good subset of C Kaz Kylheku <kaz@kylheku.com> - 2014-05-25 06:47 +0000
Re: A good subset of C Kaz Kylheku <kaz@kylheku.com> - 2014-05-25 06:43 +0000
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-05 20:59 +0100
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-05 22:28 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-05 18:57 -0400
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-06 00:26 +0100
Re: A good subset of C George Neuner <gneuner2@comcast.net> - 2014-05-06 14:21 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-07 15:43 +0100
Re: A good subset of C George Neuner <gneuner2@comcast.net> - 2014-05-07 16:03 -0400
Re: A good subset of C "BartC" <bc@freeuk.com> - 2014-05-07 21:31 +0100
Re: A good subset of C BGB <cr88192@hotmail.com> - 2014-05-07 15:41 -0500
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-05 18:46 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-06 00:42 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-06 06:48 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-07 15:40 +0100
Re: A good subset of C "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-08 06:50 -0400
Re: A good subset of C "James Harris" <james.harris.1@gmail.com> - 2014-05-08 15:43 +0100
Re: A good subset of C George Neuner <gneuner2@comcast.net> - 2014-05-08 14:41 -0400
Re: A good subset of C BGB <cr88192@hotmail.com> - 2014-05-05 19:08 -0500
csiph-web