How many levels of pointers can you have?

C

Chris Hills

Keith Thompson said:
Most current compilers fail to meet the C99 standard because certain
features are not (yet) implemented. Most current compilers *do* meet
the C90 standard (officially obsolete though it may be); deviations
from C90 are typically bugs, usually minor ones, not features that
have not yet been implemented.

Generally true. However many 8 bit compilers do not always have the full
feature set for C90.
C90 conformance is a useful concept in the real world.
I agree totally. It is the practical C standard in use.
If a
compiler's documentation claims that it conforms to C90, I can use my
officially obsolete copy of the C90 standard to find out how the
compiler will behave. If it fails to behave as it claims to, I can
cite the C90 standard in my bug report.

However the documentation for the compiler will usually tell you where
the compiler differs from the standard. If they have stated that in the
manual when you send in your "bug report" they will refer you back to
the page in the manual and close the report.

If it were a certified Ada compiler you would have a point. There is no
such thing as a Certified C compiler in the same way.

There are validation reports for C compilers but these document the
differences between the compiler and the C standard (usually C90) and
how the compilers fair on various test suites including things like
Paranoia. (Which is floating point and nothing to do with the C
standard.
That's what a standard is for, to provide a proposed contract between
implementers and users.

Sort of correct.. A "proposed" language spec. NOT a contract. The
contractual spec is the one in the compiler spec. the spec you need to
read to see the actual compiler limits.
The C90 standard, in the current state of
affairs, happens to be more useful as such a contract than the C99
standard.

I agree.
(I hope to see that change someday; if gcc's C99
conformance is ever completed, that might finally provide the impetus
to make it happen.)
I doubt it. Besides by the time the majority get close to C99 compliance
it will be C20** I expect.

Many commercial compilers use C99 complaint front ends. It is just that
the seen no need to rush to make the whole compiler c99 compliant.
But you know all that.


He didn't ask what his C compiler will actually do. He asked how many
levels of pointers C89 requires. I answered the question that he
actually asked.

NO he did NOT. What he asked was :- "How many levels of pointers can you
have?"

No reference was made to ANY c standard or any compiler or environment.
The ONLY answer is:
"12 in the standard but you have to check your compiler to see what they
have actually implemented."
He could have had any number of reasons for asking
it; perhaps it was just historical curiosity.
No he stated that it was
"This question is occur in interview. Please help me. "

You have no idea if they were discussing C in general, Standard C (which
standard) , a particular compiler or environment.

If the discussion was PIC12 the answer probably will not be 12
Do you object to any
discussion of the C90 standard?
Not at all. It is the most widely used standard
If so, you are (uncharacteristically)
attempting to impose a far stricter topicality standard than most of
feel is appropriate.

No. I said you have to check the compiler docs.
 
C

Chris Hills

Keith Thompson said:
Chris Hills said:
Knowing the limits of the tools you are using is far more important
than knowing chapter and verse on the ISO standard. (Which is a pity)
[...]

I agree that both are important; I don't agree that either is "far
more important" than the other.

I would always put knowing the tools above the standard. But then I do a
lot with safety critical Sw so I have to know exactly how the compiler
and other tools will behave.
Being familiar with the ISO C standard (not quibbling for the moment
about which one) Fair enough
enables me to write code that will work properly on
any conforming implementation. Finding a conforming implementation,
and verifying that it's (sufficiently) conforming, is another matter.

Agreed. Also much Sw does not need to be portable. In fact more I know
of is not. .
I can use handy extensions and/or work around deficiencies where
necesary, but the majority of my code's legality and behavior is
determined by the standard.
Then there will be quiet a few areas where you can't work. Also not all
departures from the standard are deficiencies Many architecture
specific extensions.
The standard provides a way to divide the considerable problem of
writing working code into two parts, one of which has to be done only
once.

I take your point. This can work in some area.
As for knowing the limits of particular implementations, there are
other newsgroups that discuss such things (gnu.gcc.*,
comp.compilers.lcc, comp.unix.solaris, microsoft.*, etc., etc.)

Yes. However the question was "I was asked in an interview who many
levels of indirection can you have." Without context the answer is
undefined in reality.

Drop into comp.arch.embedded or comp.realtime some time
 
R

Richard Heathfield

Chris Hills said (in a reply to Keith Thompson):

Knowing the limits of the tools you are using is far more important
than knowing chapter and verse on the ISO standard. (Which is a pity)

It is not always possible, when writing a C program or library, to know
which tools will be used to compile it, let alone the limits of those
tools. I often find myself in this position. In such circumstances, the
limits of the tools are more or less irrelevant from the C programmer's
perspective, since they are unknowable.
Absolutely this is why MISRA-C references C90+A1+TC1&2. In the real
world (ie not clc :) where you have to write real safety critical
programs on real hardware from 8 to 128 bit MCU's the level of
conformance, or lack of, of the "C" compiler needs to be understood
and documented.

I don't know what makes you think clc isn't part of the real world.
There were some discussions as to whether MISRA-C3 should reference
C99. Any suggestions?

Why bother? Almost nobody uses it. Why reference an almost unused
standard? I can see why you might want to refer to C99 in, say, a
tutorial - just to make people aware that it exists and broadly what
its features are - but otherwise it seems pretty pointless.
It really depends on where the majority of embedded compilers will be
in
2 years time, If the are still C95 ish that is where MISRA-C3 will
have to be as it is pointless doing a real world standard for tools
which don't exist in the mainstream.

You make my point nicely.
However if the majority
suddenly rush to C99 compliance then that is where MISRA-C 3 should
be,

....but how likely is that?
 
D

Dave Vandervies

Keith Thompson said:
Once again, the translation limits in C99 5.2.4.1 are defined *very*
narrowly. Their effect is to encourage implementations to be
reasonable, not to require them to be reasonable. A perverse
conforming implementation could specifically recognize the chosen
single program required in 5.2.4.1, and generate code equivalent to
"int main(void){}" (if the chosen program performs no I/O), and impose
much stricter limits on all other programs.

Exercise for the language lawyers:

If this script, on a system where it was able to execute successfully,
had its implementation-defined behavior defined and had a documented
program exercising all of the minimum translation requirements for which
the "translation" is correct, would it be a conforming C implementation?
Why or why not?
--------
#!/bin/sh
if [ -z "$1" ]; then
echo Usage: $0 filename
exit 0
fi

echo This program may contain a syntax error or constraint violation.
cp /bin/true a.out
--------

(V guvax, ohg unira'g irevsvrq, gung nyy V/B (vapyhqvat reebe ercbegvat)
vf nyybjrq gb snvy; vs na vzcyrzragngvba xabjf guvf jvyy unccra, gur nf-vs
ehyr fubhyq nyybj vg gb bcgvzvmr nyy fvqr-rssrpgf njnl, qvfpneq gur erghea
inyhr sebz znva, naq yrnir gur hfre jvgu n cebtenz erqhprq gb n ab-bc.
V oryvrir vg snvyf gb unaqyr #reebe qverpgvirf pbeerpgyl, gubhtu.)


dave
(it would obviously fail on every QoI measure except possibly speed, but...)
 
K

Keith Thompson

Chris Hills said:
It wasn't AFAIK

The Rational was for C89. It was an ANSI working group document AFAIK
it was never an ISO document

If it was a working group document, then it was't an ANSI standard
either, and it wasn't actually "dropped". And, as i said, it was
available; since it's non-normative, it doesn't matter much whether
it's published by ISO or not.
 
R

Richard Tobin

Malcolm McLean said:
I doubt my website would "validate as compliant HTML". That's because I edit
all the files in a plain text editor. It is too difficult to balance all the
tags, for instance, so I don't bother.

If by "not balancing all the tags" you mean omitting some start and
end tags, that may be perfectly valid. Unlike XML, SGML (of which
HTML is supposed to be an example) allows many shortcuts in that
respect for the benefit of human authors.

On the other hand, if you mean things like badly-nested elements such as

<x>some<y>random</x>stuff</y>

then it's not valid.

-- Richard
 
K

Keith Thompson

Chris Hills said:
[snip]
He didn't ask what his C compiler will actually do. He asked how many
levels of pointers C89 requires. I answered the question that he
actually asked.

NO he did NOT. What he asked was :- "How many levels of pointers can
you have?"

Please pay attention; you even quoted the question that I answered.

The *original poster* asked "How many levels of pointers can you
have?". (I didn't attempt to answer that question.)

Later in the thread, Joachim Schmitz (who is not the OP) asked:

So what does C89 require as the minmum?

That's the question I answered. The answer is 12.
 
F

Flash Gordon

Richard Heathfield wrote, On 10/06/07 22:46:
Chris Hills said (in a reply to Keith Thompson):


Why bother? Almost nobody uses it. Why reference an almost unused
standard? I can see why you might want to refer to C99 in, say, a
tutorial - just to make people aware that it exists and broadly what
its features are - but otherwise it seems pretty pointless.

<snip>

I my opinion it depends on how much clout the MISRA group has. If they
can effectively force the compiler writers for the chips used in their
domain to conform to C99 then them doing so would be a good thing in my
opinion. However, if the compiler vendors will just ignore it then MISRA
should stick to C95. After all, I don't want my car failing because the
code used a C99 feature that was not properly implemented by the compiler!
 
O

Old Wolf

Er, you haven't seen some of the resumes I've seen, then, and
subsequently interviewed the candidates with the same name at the top
of the resume. The technical ability described on the resume may have
nothing at all to do with the technical ability possessed by the
candidate

I've been told that this is endemic in American
culture, and someone even tried to argue once
that if you did NOT lie on your resumé then you
were behaving irrationally.
 
C

Charlton Wilbur

OW> I've been told that [resume padding] is endemic in American
OW> culture, and someone even tried to argue once that if you did
OW> NOT lie on your resumé then you were behaving irrationally.

There are so many people inflating their resumes that the resume of
someone who has not done the same will look anemic by comparison.

On the other hand, my resume is entirely truthful and includes
information on where I'm willing to work, and I can count on one or
two emails a week from recruiters who want me to work jobs I'm not
qualified for in geographically infeasible areas. I suspect the
resume-padding has gotten to such a point that nobody is reading them
at all any longer, and it has become some sort of ritual signalling
like peacock tail feathers.

Charlton
 
D

Dave Vandervies

OW> I've been told that [resume padding] is endemic in American
OW> culture, and someone even tried to argue once that if you did
OW> NOT lie on your resumé then you were behaving irrationally.

There are so many people inflating their resumes that the resume of
someone who has not done the same will look anemic by comparison.

I have a significantly higher ratio of job offers to job interviews than
most people I know.
This is mostly because I have trouble getting interviews when looking for
a job; most places where I've been interviewed have seemed to be impressed
with me. I have, on more than one occasion, been discussing this and
said something like "Maybe I need to lie more on my resume", and I've
found it disturbing how many people treat that as a serious suggestion.
(For the curious, a lightly edited version of the resume that got
me my current job is at <http://www.eskimo.com/~dj3vande/resume/>.
Compare with <http://www.seebs.net/res-p.html>.)


dave
 
M

Morris Dovey

Dave Vandervies wrote:
| In article <[email protected]>,
||
||| I've been told that [resume padding] is endemic in American
||| culture, and someone even tried to argue once that if you did
||| NOT lie on your resumi then you were behaving irrationally.
||
|| There are so many people inflating their resumes that the resume of
|| someone who has not done the same will look anemic by comparison.
|
| I have a significantly higher ratio of job offers to job interviews
| than most people I know.
| This is mostly because I have trouble getting interviews when
| looking for a job; most places where I've been interviewed have
| seemed to be impressed with me. I have, on more than one occasion,
| been discussing this and said something like "Maybe I need to lie
| more on my resume", and I've found it disturbing how many people
| treat that as a serious suggestion. (For the curious, a lightly
| edited version of the resume that got
| me my current job is at <http://www.eskimo.com/~dj3vande/resume/>.
| Compare with http://www.seebs.net/res-p.html.)

I can see that I've been going about this all wrong. I think I'd best
attack http://www.iedu.com/mrd/mrd_res1.html with an axe and sprinkle
in a bit of humor.
 
J

Joachim Schmitz

Default User said:
Why don't you two learn how to trim your damn quotes?
Why should I? Most of the previous posters in that thread didn't (if I got
it right, you didn't leave a lot of context to prove) and you didn't
complain to them.
Instead you swear at me, great :-(

Bye, Jojo
 
R

Richard Heathfield

Joachim Schmitz said:
...
Why should I?

Because it's the right thing to do.
Most of the previous posters in that thread didn't

What has that to do with it? People will consider you responsible for
*your* posting behaviour, not theirs.
(if I
got it right, you didn't leave a lot of context to prove) and you
didn't complain to them.

See above, where he says "you two", so he's not just picking on you.
Instead you swear at me, great :-(

He shouldn't have done that. But that's his problem, not yours. Learning
how to snip properly is your problem, not his.
 
C

Chris Hills

Flash Gordon said:
Richard Heathfield wrote, On 10/06/07 22:46:

<snip>

I my opinion it depends on how much clout the MISRA group has. If they
can effectively force the compiler writers for the chips used in their
domain to conform to C99 then them doing so would be a good thing in my
opinion.
Why?

However, if the compiler vendors will just ignore it then MISRA should
stick to C95. After all, I don't want my car failing because the code
used a C99 feature that was not properly implemented by the compiler!

Actually the compiler writers do seem to take note of MISRA-C. Many
include MISRA checkers of MISRA- compliant code. However.... MISRA-C is
a coding standard to use with tools that are in use now. That is why
it is based on C90+
 
C

Chris Hills

CBFalconer said:
I believe the major problem is updating all those libraries.

Not at all. There are several C99 libraries out there. It is just that
there is no demand for C99 in the real world.
 
D

Default User

Joachim said:
Why should I? Most of the previous posters in that thread didn't (if
I got it right, you didn't leave a lot of context to prove) and you
didn't complain to them.

Try to learn to read. I left two attributions, you and Chris Hills, who
are responsible for the back and forth non-trimmed posting. I
specifically said "you two".

Besides, regardless of whether anybody else did or did not trim quotes,
you didn't.




Brian
 
J

Joachim Schmitz

Richard Heathfield said:
Joachim Schmitz said:

Because it's the right thing to do.
So? Well maybe it is, but certainly not if asked with that tone, that was my
main concern.
What has that to do with it? People will consider you responsible for
*your* posting behaviour, not theirs.


See above, where he says "you two", so he's not just picking on you.
Oops, missed the 'two', reading can be of advandage sometimes ;-)
But insulting two doesn't make it any better, does it?
He shouldn't have done that. But that's his problem, not yours.
That was what I'm complaining about.
Learning how to snip properly is your problem, not his.
Point taken... bit I did (and still don't) consided that particular one
having been too long.

Bye, Jojo
 
J

Joachim Schmitz

Then you are a complete idiot who will be ignored.
I can live getting ignored by you then. And will do the same to you.
Now that proves you are an idiot.
That only proves that you're impolite and a troll. If insults is all you can
come up with...
You will never work in safety critical or high reliability SW development
with an attitude like that.
Now guess where I work...
It is unprofessional and dangerous.
Of course proper testing of the apps is needed befor deployment. Relying on
one's own coding capabilities and relying on some compiler to behave a per
it's specification won't do.
Regardless whether this specification is in a standard or in the compilers
documentation.

They don't they just say they are C compilers.
No, some claim compliance with ANSI C89, others with ISO C90 and very few
even ISO C99.
Wrtitten on the package and in their documentation. Part of the contract to
the buyer.
They don't claim compliance. It's that simple.
Not here. I'm using a compiler where the vendor claims it to be ANSI C89
compliant. Should I find out that it is not (and can prove it), I'll get the
vendor to fix that.
Should he refuse a fix, I'll file a case at court for violating a contract
and for distortion of competition.
Well, in this case maybe not, pretty hard to sue your own employer on these
grounds...

Bye, Jojo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top