On 07.07.2015 15:57, Richard Bell wrote: > This assumes the input/output types are gr_complex, which makes me think > is causing the problems I'm seeing. I tried to look in other built-in > blocks to see how they work but it hasn't cleared up my confusion. For > example, in 'Stream to Tagged Stream', which lets users select the type, > the lines above are declared as follows: > > const *unsigned char* *in = (const *unsigned char* *) input_items[0]; > *unsigned char* *out = (*unsigned char* *) output_items[0]; > > Why would this work if the user selects complex type from GRC?
Because the block itself is agnostic of the data, and 'unsigned char' is a safe type to declare pointers. You'll notice that we drag an 'item size' attribute around which is then used for the actual data copying. > The big question is, how do I properly define the buffer pointer types > for user selectable type blocks in the C++ code? There's 2 cases: Either the block doesn't care about the actual type (e.g. as in stream to tagged stream), then you use the char-pointer + item size. Or your block *does* care about the type, then you need to reimplement the block for every type (e.g. the add blocks). We do have a template mechanism for this, mind you. M _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio