I am trying to split up format strings into shorter lengths for later
use. (In realtime C code intended to display arbitrary content on LCD
screens)

                retval = snprintf(lcd.insts[i].pages[p].fmt,
                                  j - k + 2,
                                  "%s",
                                  fmt_strings[i] + k);

                rtapi_print("fmt %i = %s\n", p, lcd.insts[i].pages[p].fmt);

I am fairly sure that the first line works as-expected, as later code
which is basically counting "%" characters is finding the expected
number.
However, the output of the rtapi_print is along the lines of:

"fmt 0 = LinuxCNC\nX position = %f\nY position = 544501094\nZ
position=540876848"
for an input string of
"LinuxCNC\nX position = %f\nY position = %i\nZ position=%i"

So, it seems that the rtapi_print is possibly running twice through
the format specifier ("fmt %i = %s\n")  and parsing the %i (but not
the %f) in the argument string.
It then seems to be taking random memory locations as the input data.
(Is this bad? It seems like it should be)

This does lead to an interesting question. Is there a way I can use
this behaviour to pass a compile-time-unknown number of parameters to
a format string?
My plan was to interpret each format specifier individually, then
concatenate into the finished string, passing in one value (from a HAL
pin) at a time. But if I could perhaps pass an array of pointers to
hal pins, life would be easier.

-- 
atp
If you can't fix it, you don't own it.
http://www.ifixit.com/Manifesto

------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to