 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
CBFalconer Guest
|
Posted: Thu Jan 27, 2005 1:18 am Post subject: Re: size of a byte and int? |
|
|
Chris Torek wrote:
| Quote: | 42Bastian Schick <bastian42 (AT) yahoo (DOT) com> wrote:
Means, only the compiler or what comes with it should define
types with leading underscores ?
Means "the implementor" -- the guy writing your compiler and
surrounding code.
(Actually, IIRC I've seen in in some Linux source and found it
appealing.)
Suppose I, as your implementor, put this in <stdio.h> (contrary
to the standard's requirement that I do not do this):
#define i 42
#define tmp "ha ha"
Now you, the user, write your program, including a function:
#include
...
void f(...) {
int i;
char *tmp;
...
When you go to compile this, the compiler "sees" the top of your
function f() written as:
int 42;
char *"ha ha";
and gives you a bunch of strange syntax error messages.
I, the implementor, keep out of you way by making sure I do this:
/* flags for __sflag field */
#define __SRD 1
#define __SWR 2
[etc]
You, the user, keep out of my way by not using names like "__SRD".
For the most part, all the names starting with "_" are mine, and
all the rest are yours. If I define "i" or "tmp", it is my fault
for breaking your code. If you define _ZOG, it is your fault for
breaking my code.
Now, what if you are neither the implementor, nor the end user?
What if you are the guy writing a library for doing graphics, or
playing chess, or whatever? What names do *you* get? (The
Standard answereth not.)
|
Which is all nice and clear for those not yet aware. As far as the
last paragraph is concerned, common practice is to add a
(hopefully) unique prefix to all names in that library. Some use
prefix, underscore, and then the normal name, as in "hsh_find". I
leave out the underscore. With luck it all works.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
|
|
| Back to top |
|
 |
Zilla Guest
|
Posted: Thu Jan 27, 2005 3:25 am Post subject: Re: size of a byte and int? |
|
|
yeah, I think I get to know them, too.
Thank you.
|
|
| Back to top |
|
 |
42Bastian Schick Guest
|
Posted: Thu Jan 27, 2005 11:13 am Post subject: Re: size of a byte and int? |
|
|
On 26 Jan 2005 19:25:59 -0800, "Zilla" <bitzilla (AT) gmail (DOT) com> wrote:
| Quote: | yeah, I think I get to know them, too.
Thank you.
|
???? Know what ?
--
42Bastian
Do not email to [email]bastian42 (AT) yahoo (DOT) com[/email], it's a spam-only account
Use <same-name>@monlynx.de instead !
|
|
| Back to top |
|
 |
42Bastian Schick Guest
|
Posted: Thu Jan 27, 2005 11:14 am Post subject: Re: size of a byte and int? |
|
|
| Quote: |
Didn't know that C defines the term byte.
I hope you don't write C programs.
|
I do, but prefer assembler
--
42Bastian
Do not email to [email]bastian42 (AT) yahoo (DOT) com[/email], it's a spam-only account
Use <same-name>@monlynx.de instead !
|
|
| Back to top |
|
 |
42Bastian Schick Guest
|
Posted: Thu Jan 27, 2005 11:17 am Post subject: Re: size of a byte and int? |
|
|
| Quote: |
Suppose I, as your implementor, put this in <stdio.h> (contrary to
the standard's requirement that I do not do this):
#define i 42
#define tmp "ha ha"
Now you, the user, write your program, including a function:
#include <stdio.h
...
void f(...) {
int i;
char *tmp;
...
When you go to compile this, the compiler "sees" the top of your
function f() written as:
int 42;
char *"ha ha";
and gives you a bunch of strange syntax error messages.
I, the implementor, keep out of you way by making sure I do this:
/* flags for __sflag field */
#define __SRD 1
#define __SWR 2
[etc]
You, the user, keep out of my way by not using names like "__SRD".
For the most part, all the names starting with "_" are mine, and
all the rest are yours. If I define "i" or "tmp", it is my fault
for breaking your code. If you define _ZOG, it is your fault for
breaking my code.
|
Now, that's clear. Thanks.
--
42Bastian
Do not email to [email]bastian42 (AT) yahoo (DOT) com[/email], it's a spam-only account
Use
|
|
| Back to top |
|
 |
toby Guest
|
Posted: Thu Jan 27, 2005 2:15 pm Post subject: Re: size of a byte and int? |
|
|
In practice, though, such streams would almost always be files of 8-bit
characters - even if the type happens to be wider. Of course, in
theory, you're right, that could be a portability concern.
I was referring above to being unable to directly address 8 bit data
(packed strings, or blocks read from such an 8 bit packed file), and
requiring shift (or swap) and mask operations to do so.
|
|
| Back to top |
|
 |
CBFalconer Guest
|
Posted: Thu Jan 27, 2005 5:45 pm Post subject: Re: size of a byte and int? |
|
|
toby wrote:
| Quote: |
In practice, though, such streams would almost always be files of
8-bit characters - even if the type happens to be wider. Of course,
in theory, you're right, that could be a portability concern.
I was referring above to being unable to directly address 8 bit
data (packed strings, or blocks read from such an 8 bit packed
file), and requiring shift (or swap) and mask operations to do so.
|
Please desist from publishing these orphaned quoteless articles.
There is no 'above' to which to refer. The google view of a
newsgroup is sadly distorted from reality, as is their foul posting
interface. See my sig below for a partial cure. Better yet, get a
real newsreader. (Netscape, Thunderbird, Xnews all come to mind.
Xnews is only for Windoze)
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
|
|
| Back to top |
|
 |
toby Guest
|
Posted: Thu Jan 27, 2005 6:37 pm Post subject: Re: size of a byte and int? |
|
|
CBFalconer wrote:
| Quote: | ...
Please desist from publishing these orphaned quoteless articles.
|
This is inadvertent - in addition to all their other sins, Google
Groups is now incompatible with my habits. Thanks for the headsup, I'll
try to remember to take the long route through their interface in
future, which allows correct quoting.
In this case the context of the posting was fairly obvious.
--Toby
|
|
| Back to top |
|
 |
Chris Torek Guest
|
Posted: Fri Jan 28, 2005 1:28 am Post subject: Re: size of a byte and int? |
|
|
In article <41f6c9cb.1328362468 (AT) News (DOT) individual.net>
Dave Hansen <iddw (AT) hotmail (DOT) com> wrote:
| Quote: | FWIW, the Univac never had a C compiler when I was working with it.
FORTRAN 77, Pascal, PL/I, COBOL, SNOBOL, Lisp, GPSS, Prolog, and many
others I'm forgetting now, but no C.
|
There *was* at least one 1100-series C compiler. I never used it,
but I know people who did. The compiler had 9-bit "char" (ASCII
quaterword, as you would expect), 18-bit "short", and 36-bit "long".
I think, but am not sure, that "int" was also 36 bits. All were
of course ones' complement.
(This predated the 1989 C Standard, and I imagine various things
the compiler did would not have been conforming. Note, however,
that ones' complement is explicitly allowed.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
|
|
| Back to top |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group
|