#emc-devel | Logs for 2010-06-07

Back
[18:35:34] <andypugh> OK, so, in general I should use "static double" for values that need to persist between calls to the function and only use the hal_***_t types in C code that creates pins?
[18:36:03] <andypugh> And I can skip the "static" for cases where a persistent value is not required?
[18:37:53] <jepler> FUNCTION(_) {...} is just a convenience for declaring a C function with the right name and parameters. static and non-static things declared at function scope have the same meaning as in C.
[18:39:04] <andypugh> You are assuming that I know the meanings in C :-)
[18:40:18] <jepler> no; I'm hoping that with that explanation you can go off searching for explanations more eloquent and technically accurate than mine
[18:40:56] <SWPadnos> andypugh, just be careful about multiple instances
[18:41:34] <SWPadnos> if someone has 3 motors, you probably don't want the data static, since the same function will be called for all the instances of the component (with a different data pointer)
[18:41:38] <jepler> yes, in FUNCTION(_) { static int x=0; }, x is in effect shared for all the instances
[18:41:52] <andypugh> Actually, one point of C-bafflement: you pointed me at serport.comp yesterday. Underneath the RTAP_MP_ARRAY_INT line there is "int get_count(void) { " is that a function declaration that does not get called anyhere, or does it actually run through means I can't fathom?
[18:42:16] <SWPadnos> doesn't "variable" put extra data in a per-instance struct?
[18:42:36] <SWPadnos> that's in the comp manual :)
[18:42:47] <jepler> andypugh: the latter. Most comp components take a count= parameter. But if you specify 'option count_function yes;' then get_count() is called and its return value is the number of instances
[18:42:49] <andypugh> That would explain what "variable" is for, certainly.
[18:43:27] <andypugh> jepler: aha!
[18:43:46] <SWPadnos> the get_count thing is the thing in the manual
[18:44:13] <jepler> in the case of serport I think it counts the number of port addresses specified(?)
[18:45:47] <andypugh> It's a fun use of the for ( ; ; ) structure, certainly.
[19:29:35] <ries_> ries_ is now known as ries
[22:21:53] <ries_> ries_ is now known as ries