473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Portable int?

I'm just curious, why don't we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent? I do not have programming experience on other
platform except M$ Windows and Linux.

Thank you.
Nov 13 '05 #1
41 2108

"Phui Hock" <ph******@myway.com> wrote in message
news:a9**************************@posting.google.c om...
I'm just curious, why don't we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent? I do not have programming experience on other
platform except M$ Windows and Linux.


Cuz that's stupid. The reason "int" isn't always a fixed size [it does have
minimums btw] is that it's meant to be an ideal platform size. E.g. for the
8086 it's 16-bits while for the 68000 it's 32-bits.

The idea is if I want something simple like

int x;
for (x = 0; x < strlen(buf); x++) {
buf[x] = tolower(buf[x]);
}

[or whatever].... the variable "x" should be easily manageable [e.g. not
32-bits on an 8086 and not 16-bits on a 68k].

A "long" was always meant to be "slightly less convenient but larger range".
That's not always the case though. on 68k/386 compilers "long" is typically
synonymous for "int" [except when array expressions are present cuz we all
know they must be int].

Tom
Nov 13 '05 #2
Tom St Denis wrote:

"Phui Hock" <ph******@myway.com> wrote in message
news:a9**************************@posting.google.c om...
I'm just curious, why don't we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent? I do not have programming experience on other
platform except M$ Windows and Linux.


Cuz that's stupid. The reason "int" isn't always a fixed size [it does have
minimums btw] is that it's meant to be an ideal platform size. E.g. for the
8086 it's 16-bits while for the 68000 it's 32-bits.

The idea is if I want something simple like

int x;
for (x = 0; x < strlen(buf); x++) {
buf[x] = tolower(buf[x]);
}

[or whatever].... the variable "x" should be easily manageable [e.g. not
32-bits on an 8086 and not 16-bits on a 68k].

A "long" was always meant to be "slightly less convenient but larger range".
That's not always the case though. on 68k/386 compilers "long" is typically
synonymous for "int" [except when array expressions are present cuz we all
know they must be int].


I was nodding my head and agreeing with you right up
until that final [remark]. Would you mind explaining just
what it is "we all know," because I can't figure it out.
What's an "array expression," and what has it to do with
the int-ness of anything?

--
Er*********@sun.com
Nov 13 '05 #3

"Eric Sosman" <Er*********@sun.com> wrote in message
news:3F***************@sun.com...
I was nodding my head and agreeing with you right up
until that final [remark]. Would you mind explaining just
what it is "we all know," because I can't figure it out.
What's an "array expression," and what has it to do with
the int-ness of anything?


When an expression is used to index an array...e.g.

int *p;

p[(some expression)] = (some other expression);

The expression on the left has to [technically] evaluate to an integer "int"
data type. I'm fairly certain it's a rule but I couldn't quote you the
section/page num of it.

Tom
Nov 13 '05 #4
Tom St Denis <to********@iahu.ca> scribbled the following:
"Eric Sosman" <Er*********@sun.com> wrote in message
news:3F***************@sun.com...
I was nodding my head and agreeing with you right up
until that final [remark]. Would you mind explaining just
what it is "we all know," because I can't figure it out.
What's an "array expression," and what has it to do with
the int-ness of anything?
When an expression is used to index an array...e.g. int *p; p[(some expression)] = (some other expression); The expression on the left has to [technically] evaluate to an integer "int"
data type. I'm fairly certain it's a rule but I couldn't quote you the
section/page num of it.


AFAIK you're wrong. It doesn't have to evaluate to int. It merely has to
evaluate to some type that is assignable to int. For example, p[0l]
should be valid, as should be p[*"Hello world!"]. What about p[0.0]?
But, AYCS, that's only AFAIK, and it might be that WIKIW. YHBW. HTH,
HAND.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"This is a personnel commuter."
- Train driver in Scientific American
Nov 13 '05 #5

"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bo**********@oravannahka.helsinki.fi...
AFAIK you're wrong. It doesn't have to evaluate to int. It merely has to
evaluate to some type that is assignable to int. For example, p[0l]
should be valid, as should be p[*"Hello world!"]. What about p[0.0]?
But, AYCS, that's only AFAIK, and it might be that WIKIW. YHBW. HTH,
HAND.


Seems you're right. Given

int main(void)
{
char buf[10];

buf[0l] = 'a';
buf[0ul] = 'a';
buf[*"hello"] = 'a';
buf[0.0] = 'a';
return 0;
}

tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
test.c: In function `main':
test.c:7: warning: array subscript has type `char'
test.c:8: array subscript is not an integer

Tom
Nov 13 '05 #6

On Tue, 11 Nov 2003, Tom St Denis wrote:

p[(some expression)] = (some other expression);

[Tom thought...] The expression on the left has to [technically]
evaluate to an integer "int" data type. I'm fairly certain it's a rule
but I couldn't quote you the section/page num of it.


Close, but no cigar. The array-indexing [] operator takes
one pointer to a (complete) object type and one integer type.
From N869 s6.5.2.1 (Array subscripting):

[#1] One of the expressions [i.e., 'p' or '(some expression)', above]
shall have type ``pointer to object type'', the other expression
shall have integer type, and the result has type ``type''.

The integer types are described in section 6.2.5, particularly #17.

HTH,
-Arthur
Nov 13 '05 #7

"Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> wrote in message
news:Pi***********************************@unix50. andrew.cmu.edu...

On Tue, 11 Nov 2003, Tom St Denis wrote:

p[(some expression)] = (some other expression);

[Tom thought...] The expression on the left has to [technically]
evaluate to an integer "int" data type. I'm fairly certain it's a rule
but I couldn't quote you the section/page num of it.


Close, but no cigar. The array-indexing [] operator takes
one pointer to a (complete) object type and one integer type.
From N869 s6.5.2.1 (Array subscripting):

[#1] One of the expressions [i.e., 'p' or '(some expression)', above]
shall have type ``pointer to object type'', the other expression
shall have integer type, and the result has type ``type''.

The integer types are described in section 6.2.5, particularly #17.


Swing and a miss. What probably happend is that someone else asked this, I
read the reply and munged "integer type" with "int".

Tom
Nov 13 '05 #8
On 11 Nov 2003 12:42:13 -0800, ph******@myway.com (Phui Hock) wrote:
I'm just curious, why don't we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent? I do not have programming experience on other
platform except M$ Windows and Linux.

Thank you.


When the size of an integer variable is critical, we do. Otherwise,
the implementation probably has good reasons for the default size.

You do need to remember that support for the uint-type integers is not
universal.

--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 13 '05 #9
Phui Hock wrote:
Why don't we just use uint8_t or uint16_t for example
to declare an integer type storage
when we know int is always platform-dependent?
I do not have programming experience
on other platform except M$ Windows and Linux.


Because there is no guarantee that uint8_t or uint16_t
will actually be supported by every C [99] compiler.
Use them only if you are certain that they are supported
on every potential target platform for your software.

To my knowledge, they are supported
by every C99 compiler for Windows on Intel computers
and Linux on Intel computers and IBM/Motorola PowerPC.

Nov 13 '05 #10

"Tom St Denis" <to********@iahu.ca> wrote in message
news:5U*****************@news04.bloor.is.net.cable .rogers.com...

"Phui Hock" <ph******@myway.com> wrote in message
news:a9**************************@posting.google.c om...
I'm just curious, why don't we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent? I do not have programming experience on other
platform except M$ Windows and Linux.
Cuz that's stupid. The reason "int" isn't always a fixed size [it does

have minimums btw] is that it's meant to be an ideal platform size. E.g. for the 8086 it's 16-bits while for the 68000 it's 32-bits.

The idea is if I want something simple like

int x;
for (x = 0; x < strlen(buf); x++) {
buf[x] = tolower(buf[x]);
}

[or whatever].... the variable "x" should be easily manageable [e.g. not
32-bits on an 8086 and not 16-bits on a 68k].

A "long" was always meant to be "slightly less convenient but larger range". That's not always the case though. on 68k/386 compilers "long" is typically synonymous for "int" [except when array expressions are present cuz we all
know they must be int].

Tom


The 68000 is a hybrid 16-bit/32-bit processor. The title of Motorola's
manual is "M68000 16/32-bit microprocessor".
Registers are 32-bits. But the ALU is only 16-bits. Calculation on 32-bit
numbers is done in two operations using micro code. Most 32-bit instructions
takes twice the time of the corresponding 16-bit instruction.
Some C compilers use 16-bit int. Others 32-bits. Others again make the
length of int a user option.

Carsten Hansen
Nov 13 '05 #11
Tom St Denis <to********@iahu.ca> wrote:

<snip>
tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c

^^^^^^

<OT> Shame on you! </OT>

Alex
Nov 13 '05 #12
In <bo*************@ID-190529.news.uni-berlin.de> Alex <al*******@hotmail.com> writes:
Tom St Denis <to********@iahu.ca> wrote:

<snip>
tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c

^^^^^^

<OT> Shame on you! </OT>


It's typical for clueless people who are unable to understand the big
advantages of having limited access rights on the system.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #13
Alex <al*******@hotmail.com> wrote:
Tom St Denis <to********@iahu.ca> wrote:
tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c

^^^^^^

<OT> Shame on you! </OT>


He'll learn. Sooner or later, they all do. Of course, it'll cost him
half a dozen years' worth of files, but hey, who cares about porn JPEGs
and C source which voids main()?

Richard
Nov 13 '05 #14

"Alex" <al*******@hotmail.com> wrote in message
news:bo*************@ID-190529.news.uni-berlin.de...
Tom St Denis <to********@iahu.ca> wrote:

<snip>
tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c

^^^^^^

<OT> Shame on you! </OT>


I run gentoo and the only server I have [apache] runs as user/group
apache....

What is your point again?

Oh yeah, stupid ass lame script kiddie comment about how l33t you are.

Tom
Nov 13 '05 #15

"Richard Bos" <rl*@hoekstra-uitgeverij.nl> wrote in message
news:3f*****************@news.nl.net...
Alex <al*******@hotmail.com> wrote:
Tom St Denis <to********@iahu.ca> wrote:
tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c

^^^^^^

<OT> Shame on you! </OT>


He'll learn. Sooner or later, they all do. Of course, it'll cost him
half a dozen years' worth of files, but hey, who cares about porn JPEGs
and C source which voids main()?


How so?

Go ahead and break into apache. You will get my website [provided you can
do it]. That's the only server I'm running. I build all my programs from
scratch. I do weekly backups, um... whatelse...

oh yeah, you're an ass who doesn't know jack f'ing squat.

Tom
Nov 13 '05 #16
On Thu, 13 Nov 2003 14:27:41 GMT, "Tom St Denis" <to********@iahu.ca>
wrote:

"Richard Bos" <rl*@hoekstra-uitgeverij.nl> wrote in message
news:3f*****************@news.nl.net...
Alex <al*******@hotmail.com> wrote:
> Tom St Denis <to********@iahu.ca> wrote:
>
> > tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
> ^^^^^^
>
> <OT> Shame on you! </OT>


He'll learn. Sooner or later, they all do. Of course, it'll cost him
half a dozen years' worth of files, but hey, who cares about porn JPEGs
and C source which voids main()?


How so?

Go ahead and break into apache. You will get my website [provided you can
do it]. That's the only server I'm running. I build all my programs from
scratch. I do weekly backups, um... whatelse...


I thought Richard was predicting that sooner or later, you're going to
do it to yourself, no Apache cracking needed. I'm not brave enough to
do development from root.

--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 13 '05 #17
Dan Pop <Da*****@cern.ch> scribbled the following:
In <bo*************@ID-190529.news.uni-berlin.de> Alex <al*******@hotmail.com> writes:
Tom St Denis <to********@iahu.ca> wrote:
<snip>
tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c ^^^^^^

<OT> Shame on you! </OT>

It's typical for clueless people who are unable to understand the big
advantages of having limited access rights on the system.


I don't know very much about Unix. I mean, I'm by far the most Unix-
knowledgeable person in my family (next comes my 13-year-old brother,
whose Unix experience is limited to trying Linux out once), but I
still don't know very much. Therefore I always run as non-root unless
I have a special reason to run as root.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"C++. C++ run. Run, ++, run."
- JIPsoft
Nov 13 '05 #18

"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bp**********@oravannahka.helsinki.fi...
Dan Pop <Da*****@cern.ch> scribbled the following:
In <bo*************@ID-190529.news.uni-berlin.de> Alex <al*******@hotmail.com> writes:
Tom St Denis <to********@iahu.ca> wrote:
<snip>
tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
^^^^^^

<OT> Shame on you! </OT>

It's typical for clueless people who are unable to understand the big
advantages of having limited access rights on the system.


I don't know very much about Unix. I mean, I'm by far the most Unix-
knowledgeable person in my family (next comes my 13-year-old brother,
whose Unix experience is limited to trying Linux out once), but I
still don't know very much. Therefore I always run as non-root unless
I have a special reason to run as root.


Oddly enough, that sounds very much like the behavior of those who *do* know
a lot about Unix.

I don't know a lot about lawnmowers, so I never use mine underwater or
overhead.
Nov 13 '05 #19
BruceS <no****@nospam.net> scribbled the following:
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bp**********@oravannahka.helsinki.fi...
Dan Pop <Da*****@cern.ch> scribbled the following:
> In <bo*************@ID-190529.news.uni-berlin.de> Alex <al*******@hotmail.com> writes: >>Tom St Denis <to********@iahu.ca> wrote:
>><snip>
>>> tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
>> ^^^^^^
>>
>><OT> Shame on you! </OT>
> It's typical for clueless people who are unable to understand the big
> advantages of having limited access rights on the system.


I don't know very much about Unix. I mean, I'm by far the most Unix-
knowledgeable person in my family (next comes my 13-year-old brother,
whose Unix experience is limited to trying Linux out once), but I
still don't know very much. Therefore I always run as non-root unless
I have a special reason to run as root.

Oddly enough, that sounds very much like the behavior of those who *do* know
a lot about Unix.


I know enough to know that I don't know everything. I am well aware of
the things I could accidentally do if I ran as root. If I knew more, I
wouldn't do those things even if I ran as root...

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I said 'play as you've never played before', not 'play as IF you've never
played before'!"
- Andy Capp
Nov 13 '05 #20

"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bp**********@oravannahka.helsinki.fi...
BruceS <no****@nospam.net> scribbled the following:
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bp**********@oravannahka.helsinki.fi...
Dan Pop <Da*****@cern.ch> scribbled the following:
> In <bo*************@ID-190529.news.uni-berlin.de> Alex

<al*******@hotmail.com> writes:
>>Tom St Denis <to********@iahu.ca> wrote:
>><snip>
>>> tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
>> ^^^^^^
>>
>><OT> Shame on you! </OT>

> It's typical for clueless people who are unable to understand the big
> advantages of having limited access rights on the system.

I don't know very much about Unix. I mean, I'm by far the most Unix-
knowledgeable person in my family (next comes my 13-year-old brother,
whose Unix experience is limited to trying Linux out once), but I
still don't know very much. Therefore I always run as non-root unless
I have a special reason to run as root.
Oddly enough, that sounds very much like the behavior of those who *do*

know a lot about Unix.


I know enough to know that I don't know everything. I am well aware of
the things I could accidentally do if I ran as root. If I knew more, I
wouldn't do those things even if I ran as root...


Yes. IME, those who know Unix well recognize that they don't know
everything, are very careful about being root, and know that fat fingers can
be a problem even when not root but are worse as root. Too many of those who
don't know Unix well often run as root, because they can "do anything"
without permission complaints.
I once saw a coworker attempt to restart inetd. He first got its pid, say
32, then typed something like "kill 1 32". He was surprised when the machine
went to single-user mode.
Nov 13 '05 #21
On Thu, 13 Nov 2003 08:56:36 -0700, Alan Balmer wrote:
On Thu, 13 Nov 2003 14:27:41 GMT, "Tom St Denis" <to********@iahu.ca>
wrote:

"Richard Bos" <rl*@hoekstra-uitgeverij.nl> wrote in message
news:3f*****************@news.nl.net...
Alex <al*******@hotmail.com> wrote:

> Tom St Denis <to********@iahu.ca> wrote:
>
> > tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
> ^^^^^^
>
> <OT> Shame on you! </OT>

He'll learn. Sooner or later, they all do. Of course, it'll cost him
half a dozen years' worth of files, but hey, who cares about porn JPEGs
and C source which voids main()?


How so?

Go ahead and break into apache. You will get my website [provided you can
do it]. That's the only server I'm running. I build all my programs from
scratch. I do weekly backups, um... whatelse...


I thought Richard was predicting that sooner or later, you're going to
do it to yourself, no Apache cracking needed. I'm not brave enough to
do development from root.


Hey maybe he's running Lindows. Doesn't it default to running everything
as root?
Nov 13 '05 #22
Tom St Denis <to********@iahu.ca> wrote:
"Alex" <al*******@hotmail.com> wrote in message
news:bo*************@ID-190529.news.uni-berlin.de...
Tom St Denis <to********@iahu.ca> wrote:

<snip>
> tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c ^^^^^^

<OT> Shame on you! </OT>

I run gentoo and the only server I have [apache] runs as user/group
apache.... What is your point again? Oh yeah, stupid ass lame script kiddie comment about how l33t you are.


Uh.

Obviously you entirely failed to grasp my point. Doing development
as root is idiotic, not because of script kiddies but because of what
you, yourself, will accidentally do sooner or later.
Alex
Nov 13 '05 #23
"Tom St Denis" <to********@iahu.ca> wrote in message news:<xx*************@news04.bloor.is.net.cable.ro gers.com>...
How so?

Go ahead and break into apache. You will get my website [provided you can
do it]. That's the only server I'm running.
Don't you mean TSR, Tom? :)

I build all my programs from scratch.
In this day and age, that makes you a very incompetant manager.

I do weekly backups, um... whatelse...

oh yeah, you're an ass who doesn't know jack f'ing squat.

Tom


cc -o mirror mirror.c

If only C were a more expressive language, and you were worth it, I'd
come up with a better quip. :)
David.
Nov 13 '05 #24
In <b4******************@newsread1.news.pas.earthlink .net> "BruceS" <no****@nospam.net> writes:

"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bp**********@oravannahka.helsinki.fi...
Dan Pop <Da*****@cern.ch> scribbled the following:
> In <bo*************@ID-190529.news.uni-berlin.de> Alex<al*******@hotmail.com> writes: >>Tom St Denis <to********@iahu.ca> wrote:
>><snip>
>>> tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
>> ^^^^^^
>>
>><OT> Shame on you! </OT>

> It's typical for clueless people who are unable to understand the big
> advantages of having limited access rights on the system.


I don't know very much about Unix. I mean, I'm by far the most Unix-
knowledgeable person in my family (next comes my 13-year-old brother,
whose Unix experience is limited to trying Linux out once), but I
still don't know very much. Therefore I always run as non-root unless
I have a special reason to run as root.


Oddly enough, that sounds very much like the behavior of those who *do* know
a lot about Unix.


The more you know about Unix the more you realise how easy it is to shoot
yourself in the foot by having more privileges than strictly needed for
the job...

I like a sharp tool when I need one, but I put it back in its sheath
as soon as I'm done with it.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #25
BruceS <no****@nospam.net> scribbled the following:
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bp**********@oravannahka.helsinki.fi...
I know enough to know that I don't know everything. I am well aware of
the things I could accidentally do if I ran as root. If I knew more, I
wouldn't do those things even if I ran as root...
Yes. IME, those who know Unix well recognize that they don't know
everything, are very careful about being root, and know that fat fingers can
be a problem even when not root but are worse as root. Too many of those who
don't know Unix well often run as root, because they can "do anything"
without permission complaints.
I once saw a coworker attempt to restart inetd. He first got its pid, say
32, then typed something like "kill 1 32". He was surprised when the machine
went to single-user mode.


I've always wondered what would happen if I killed process 1, init. What
causes the computer to react to this? The kernel itself? I take it the
kernel doesn't have a process id, but is instead always running,
incapable of being killed?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"How come even in my fantasies everyone is a jerk?"
- Daria Morgendorfer
Nov 13 '05 #26
Joona I Palaste <pa*****@cc.helsinki.fi> wrote in message news:<bp**********@oravannahka.helsinki.fi>...
Dan Pop <Da*****@cern.ch> scribbled the following:
It's typical for clueless people who are unable to understand the big
advantages of having limited access rights on the system.
I don't know very much about Unix.


There are people here who do know plenty about Unix who agree with you
on your statement below.

<snip> Therefore I always run as non-root unless
I have a special reason to run as root.


And that classes you with those who /do/ know a lot about Unix, as
well as the more clueful among those who know a good bit about Unix.
Doing routine stuff as root is pretty risky and classes you as a
rather clueless newbie or a clue-resistant moron. Both kinds of people
are just waiting to be smacked down by their own ignorance.
Nov 13 '05 #27
Richard Bos wrote:
He'll learn. Sooner or later, they all do. Of course, it'll cost him
half a dozen years' worth of files, but hey, who cares about porn JPEGs
and C source which voids main()?


I don't know anything about TSD's taste in JPEGs, but I'm fairly sure he
knows that main() returns int.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #28
On Thu, 13 Nov 2003 14:27:41 GMT, in comp.lang.c , "Tom St Denis"
<to********@iahu.ca> wrote:

"Richard Bos" <rl*@hoekstra-uitgeverij.nl> wrote in message
news:3f*****************@news.nl.net...
Alex <al*******@hotmail.com> wrote:
> Tom St Denis <to********@iahu.ca> wrote:
>
> > tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
> ^^^^^^
>
> <OT> Shame on you! </OT>
He'll learn. Sooner or later, they all do. Of course, it'll cost him
half a dozen years' worth of files, but hey, who cares about porn JPEGs
and C source which voids main()?


How so?


you seem to be logged in as root. Sooner or later you'll slip up and
accidentally rm -R /*
oh yeah, you're an ass who doesn't know jack f'ing squat.


Idiots running as root should not drop glass bricks.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
Nov 13 '05 #29
"Tom St Denis" <to********@iahu.ca> wrote in message news:<lN****************@news04.bloor.is.net.cable .rogers.com>...
"Eric Sosman" <Er*********@sun.com> wrote in message
news:3F***************@sun.com...
I was nodding my head and agreeing with you right up
until that final [remark]. Would you mind explaining just
what it is "we all know," because I can't figure it out.
What's an "array expression," and what has it to do with
the int-ness of anything?


When an expression is used to index an array...e.g.

int *p;

p[(some expression)] = (some other expression);

The expression on the left has to [technically] evaluate to an integer "int"
data type. I'm fairly certain it's a rule but I couldn't quote you the
section/page num of it.


The expression on the left has to evaluate to a 'lvalue'. In case you
are asking the type of some_expression then that would be size_t which
is obviously some integer type guranteed to hold the size of any
object.

--
Fucking fuck fuck SCO
Imanpreet Singh Arora
isingh AT acm DOT org
Nov 13 '05 #30
ph******@myway.com (Phui Hock) wrote in message news:<a9**************************@posting.google. com>...
I'm just curious, why don't we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent?
Are these the types provided by standard C.
I do not have programming experience on other
platform except M$ Windows and Linux.

Thank you.


--
Fuck Shit SCO!
Imanpreet Singh Arora
isingh AT acm DOT org
Nov 13 '05 #31
On 13 Nov 2003 15:00:40 -0800, in comp.lang.c ,
mi************@yahoo.com (Minti) wrote:
ph******@myway.com (Phui Hock) wrote in message news:<a9**************************@posting.google. com>...
I'm just curious, why don't we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent?


Are these the types provided by standard C.


They're required to exist if the platform supports objects of that
size. Otherwise they're required /not/ to exist. This means that you
can safely use them in portable code, since it either
a) compiles and works as expected or
b) doesn't even compile
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
Nov 13 '05 #32
[snips]

On Thu, 13 Nov 2003 10:27:38 -0800, David M. Wilson wrote:
I build all my programs from scratch.


In this day and age, that makes you a very incompetant manager.


If it's in opposition to using possibly unsafe precompiled binaries, it
doesn't. Starting with a minimal base system from a trusted source, then
building the rest from examinable (and, presumably, examined) sources -
strikes me as a theoretically good thing; just time consuming and
expensive.
Nov 13 '05 #33
Mark McIntyre <ma**********@spamcop.net> wrote in message news:<ei********************************@4ax.com>. ..
On 13 Nov 2003 15:00:40 -0800, in comp.lang.c ,
mi************@yahoo.com (Minti) wrote:
ph******@myway.com (Phui Hock) wrote in message news:<a9**************************@posting.google. com>...
I'm just curious, why don't we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent?
Are these the types provided by standard C.


They're required to exist if the platform supports objects of that
size.


They are only required if the *implementation* defines an integer type
(standard or extended) with the properties needed for a given intN_t.

For example, an MC680x0 implementation could choose not to define a
16-bit integer type, even though it is supportable by the underlying
chipset.
Otherwise they're required /not/ to exist.
Well, int8_t and int16_t can't exist on implementations where CHAR_BIT
is not a multiple of 8, but appart from that, even a 1c or sm
implementation could mimic those integers under the 'as if' rule.
This means that you
can safely use them in portable code, since it either
a) compiles and works as expected or
b) doesn't even compile


By that definition, Windows programs are 'portable'.

--
Peter
Nov 13 '05 #34
Joona I Palaste <pa*****@cc.helsinki.fi> wrote:
Dan Pop <Da*****@cern.ch> scribbled the following:
In <bo*************@ID-190529.news.uni-berlin.de> Alex <al*******@hotmail.com> writes:
Tom St Denis <to********@iahu.ca> wrote:
<snip>
tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
^^^^^^
<OT> Shame on you! </OT>

It's typical for clueless people who are unable to understand the big
advantages of having limited access rights on the system.


I don't know very much about Unix.


Clue != knowledge, and you're a good example of that.

Richard
Nov 13 '05 #35
"Tom St Denis" <to********@iahu.ca> wrote:
"Richard Bos" <rl*@hoekstra-uitgeverij.nl> wrote in message
news:3f*****************@news.nl.net...
Alex <al*******@hotmail.com> wrote:
Tom St Denis <to********@iahu.ca> wrote:

> tombox root # gcc -O2 -Wall -W --std=c99 -pedantic -c test.c
^^^^^^

<OT> Shame on you! </OT>
He'll learn. Sooner or later, they all do. Of course, it'll cost him
half a dozen years' worth of files, but hey, who cares about porn JPEGs
and C source which voids main()?


How so?

Go ahead and break into apache.


I don't need to. All I need to do is wait until you type rm -rf ./* and
slip on the period key.
oh yeah, you're an ass who doesn't know jack f'ing squat.


Right. And you, I expect, are a true professional, with no personal
problems except a somewhat limited vocabulary where invective is
concerned.

Richard
Nov 13 '05 #36
Mark McIntyre <ma**********@spamcop.net> writes:
On 13 Nov 2003 15:00:40 -0800, in comp.lang.c ,
mi************@yahoo.com (Minti) wrote:
ph******@myway.com (Phui Hock) wrote in message
news:<a9**************************@posting.google .com>...
I'm just curious, why don't we just use uint8_t or uint16_t for example
to declare an integer type storage when we know int is always
platform-dependent?


Are these the types provided by standard C.


They're required to exist if the platform supports objects of that
size. Otherwise they're required /not/ to exist. This means that you
can safely use them in portable code, since it either
a) compiles and works as expected or
b) doesn't even compile


Note that uint8_t and friends are new in C99. Some C90
implementations may provide them as an extension (or you can define
them yourself, or grab Doug Gwyn's q8 library from
<http://www.lysator.liu.se/c/q8/>).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)
Nov 13 '05 #37
In <bp**********@oravannahka.helsinki.fi> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
I've always wondered what would happen if I killed process 1, init.
You can always try it. IIRC, the kernel will panic, but it may be
kernel specific.
What causes the computer to react to this? The kernel itself?
Isn't it obvious? How do you kill it? By asking the kernel to do it,
so the kernel knows that it is killing the init process. It is up to it
to decide how to react to such a request.
I take it the
kernel doesn't have a process id, but is instead always running,
incapable of being killed?


Even if it had a PID, how would you kill it, other than by asking itself
to commit suicide?

After creating the init process, the kernel goes into "passive" mode:
it merely reacts to interrupts, traps and service requests from the
processes.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #38
Dan Pop <Da*****@cern.ch> scribbled the following:
In <bp**********@oravannahka.helsinki.fi> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
I've always wondered what would happen if I killed process 1, init.
You can always try it. IIRC, the kernel will panic, but it may be
kernel specific.
I don't think I will, though. I'm fairly sure there would be no
permanent loss of data, but I would still have to reboot if the kernel
panics particularly nastily.
What causes the computer to react to this? The kernel itself? Isn't it obvious? How do you kill it? By asking the kernel to do it,
so the kernel knows that it is killing the init process. It is up to it
to decide how to react to such a request.
Hmm, so all kill signals go to the kernel, and not directly to the
process itself? It sort of makes sense. If they always went directly
to the process, then processes that ignored SIGKILL (signal number 9)
would be possible.
I take it the
kernel doesn't have a process id, but is instead always running,
incapable of being killed?

Even if it had a PID, how would you kill it, other than by asking itself
to commit suicide?


By asking itself to commit suicide, of course. That doesn't mean the
kernel will comply, though. But nothing would stop me from writing a
kernel that did comply - other than the fact that I don't know how to
write kernels.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I am not very happy acting pleased whenever prominent scientists overmagnify
intellectual enlightenment."
- Anon
Nov 13 '05 #39
In <bp**********@oravannahka.helsinki.fi> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Dan Pop <Da*****@cern.ch> scribbled the following:
In <bp**********@oravannahka.helsinki.fi> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
I've always wondered what would happen if I killed process 1, init.
You can always try it. IIRC, the kernel will panic, but it may be
kernel specific.
I don't think I will, though. I'm fairly sure there would be no
permanent loss of data, but I would still have to reboot if the kernel
panics particularly nastily.


Is this such a big deal?
What causes the computer to react to this? The kernel itself?
Isn't it obvious? How do you kill it? By asking the kernel to do it,
so the kernel knows that it is killing the init process. It is up to it
to decide how to react to such a request.


Hmm, so all kill signals go to the kernel, and not directly to the
process itself?


All signals, regardless of type. The Unix system call used for this
purpose is called "kill", but it handles all signals, including 0,
which means no signal, but check if the calling process has the
rights to send signals to the destination process.
It sort of makes sense.
It makes a lot of sense, if you want to avoid chaos in the system.
If they always went directly
to the process, then processes that ignored SIGKILL (signal number 9)
would be possible.


SIGKILL is never delivered to the process: the kernel simply kills the
process, if it determines that it is OK to do so (the requester has
adequate rights and the process is in a state in which it can be safely
killed).
I take it the
kernel doesn't have a process id, but is instead always running,
incapable of being killed?

Even if it had a PID, how would you kill it, other than by asking itself
to commit suicide?


By asking itself to commit suicide, of course. That doesn't mean the
kernel will comply, though. But nothing would stop me from writing a
kernel that did comply - other than the fact that I don't know how to
write kernels.


Each kernel allows a process to ask it to commit suicide in two ways:
halt and reboot. Otherwise, there would be no way of rebooting or
shutting down a Unix system, without pressing a switch or a button ;-)

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #40
Minti wrote:
.... snip ...
--
Fucking fuck fuck SCO
Imanpreet Singh Arora
isingh AT acm DOT org


This signature is boorish, childish, and offensive. Please revise
it.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 13 '05 #41
On 13 Nov 2003 20:32:20 -0800, in comp.lang.c , ai***@acay.com.au
(Peter Nilsson) wrote:
Mark McIntyre <ma**********@spamcop.net> wrote in message news:<ei********************************@4ax.com>. ..
On 13 Nov 2003 15:00:40 -0800, in comp.lang.c ,
mi************@yahoo.com (Minti) wrote:

(talking about precise width ints)
This means that you
can safely use them in portable code, since it either
a) compiles and works as expected or
b) doesn't even compile


By that definition, Windows programs are 'portable'.


Not entirely. The difference is that provided an implementation claims
ISO conformance, you are AFAIUI *guaranteed* that if it doesn't
support precise width integers then it won't define the types. OTOH a
platform need not support windows APIs, but can still cheerfully
define CreateWindowEx() and have it do something unexpected and/or
absurd.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
Nov 13 '05 #42

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: James Harris | last post by:
Hi, Can someone recommend a book that will teach me how to approach C programming so that code is modularised, will compile for different environments (such as variations of Unix and Windows),...
22
by: SeeBelow | last post by:
Is there any way, in C, of interacting with a running program, but still using code that is portable, at least between linux and Windows? By "interacting" it could be something as simple as...
10
by: Jason Curl | last post by:
Dear C group, I'm very interested in writing portable C, but I only have GNU, Sparc and Cygwin to compile on. What I find is the biggest problem to writing portable C is what headers to...
8
by: suresh_C# | last post by:
Dear All, What is difference between Portable Executable (PE) file and a Assembly? Thanks, Mahesh
2
by: Tull Clancey | last post by:
Hi all. I'm nearing completion of a host app that needs to send data to, and receive data back from a portable, an HP device. The application running on the portable will be a .net application....
131
by: pemo | last post by:
Is C really portable? And, apologies, but this is possibly a little OT? In c.l.c we often see 'not portable' comments, but I wonder just how portable C apps really are. I don't write...
162
by: Richard Heathfield | last post by:
I found something interesting on the Web today, purely by chance. It would be funny if it weren't so sad. Or sad if it weren't so funny. I'm not sure which. ...
409
by: jacob navia | last post by:
I am trying to compile as much code in 64 bit mode as possible to test the 64 bit version of lcc-win. The problem appears now that size_t is now 64 bits. Fine. It has to be since there are...
10
by: bramnizzle | last post by:
I don't know if this is the right thread or not, but... In my endless pursuit to hold on to my dinosaur laptop (Dell 1100 Inspiron - circa 2004)...I want to keep as much space free for my...
23
by: asit | last post by:
what is the difference between portable C, posix C and windows C ???
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.