On Thu, 11 Nov 2010 04:41 -0500, "Mark Wendt" <[email protected]>
wrote:
> On 11/10/2010 01:36 PM, Kirk Wallace wrote:

> > Somehow I got the impression that comp needed to have all variables
> > declared in the top portion of the file, and that comp stripped off the
> > top and placed the variables as needed. I also found that "comp
> > --compile foobar" creates a file "foobar.c" which might provide some
> > insight into this. It's like I see what might be a trunk, but I am not
> > seeing the elephant. I just need to be patient and look for it.
> >    
> I'm not too familiar with comp, but typically, C code global variables 
> are declared outside the "main", and local variables are declared either 
> in the body, or in the function.  Comp may differ?

You are correct for normal C, but comp has some special conditions to
deal with.  There are three kinds of variables that might be needed in
a HAL component:

1) HAL objects, like pins or parameters.  These must obviously be
declared in a HAL specific way, and comp lets you do that.

2) Variables which are not HAL objects, but which must retain their
values from one execution of the component to the next.  In normal
C you could declare these inside the function as "static", or outside
the function (with or without static).  However, neither of those will
work for a HAL component.  Those C declarations give you one copy of
the variable(s) that you declare.  But a HAL component can be used
more than once in a given configuration.  If you have 4 copies of
the "edge" component in your system, each one needs its own copies
of the variables.  So comp provides a mechanism to declare those
variables, and behind the scenes it makes sure that each instance
of the component has one.

3) Variables that do not need to retain their value from one
execution of the component to the next.  These can be declared
as normal C variables, inside the function.  Variables inside a
function that don't have "static" are created on the stack when
the function is called, and discarded when the function returns.
So each component gets its own variables, but they can't be used
to store data from one execution to the next.

Hope this helps,

John Kasunich
-- 
  John Kasunich
  [email protected]


------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to