Mark McIntyre wrote, On 29/11/07 00:33:
No offense in return, but I'd probably turn down the job anyway.
Currently I would as well.
Interviewers who ask daft or unanswerable questions don't do their
company any favours, unless they show a good understanding of why they
asked the question. In which case we'd probably both have a pretty fun
interview discussing the merits of various arcana.
An interview with one of the respected CLC regulars (interviewing or
being interviewed by) would be interesting.
Well, you and Flash can play "mine is bigger than yours" but I'm voting
with Flash for now...
:-D
Well, it's a bigger grin anyway.
As written by yourself, it was at file scope.
Indeed. If it was not at file scope and I was asked where it was
normally stored (as opposed to the requirements of the C standard) I
would suggest a register or the stack depending on register usage and
the details of the processor. On several implementations I've worked
with it is up to the developer to specify what section the stack is in,
so it could be in a section called "fred" for all the difference it makes.
Huh? a and c both have file scope. However c has internal linkage, thats
the difference. Note that scope and linkage are not the same. See 6.2.1
and 6.2.2 of the Standard.
Of course, if a is not at file scope (as now specified) they will be in
conceptually different areas.
On modern nonembedded processors, this is AFAIK pretty unlikely in fact.
In any case, just stating "on the stack" is incorrect because on a small
leaf function it is very likely to be wrong.
In my embedded days we had to estimate ROM and RAM usage, so that was
two types of memory to deal with. Of course, for RAM usage you had to
look at static storage duration and stack size (I never used a processor
where the implementation did not document a stack for auto variables),
so worst case we were concerned with three "sections". I have not
forgotten dynamic memory allocation, the rules explicitly disallowed
using it. Any further breakdown was an implementation detail you dealt
with when setting up the build environment, and I always set it up so as
to make life easy.
Oh, and I always ensured that *all* RAM was initialised as part of the
power-up RAM test, so there was in a real practical sense never an
"uninitialised section".
It was generally me that was responsible for the startup code and linker
scripts on any project I was on, so I always knew exactly where
everything was and how static variables were initialised.