discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] It must be defined inside the context of a function !


From: Activecat
Subject: [Discuss-gnuradio] It must be defined inside the context of a function !
Date: Thu, 16 Jan 2014 15:46:05 +0800

Dear Sir,

Below code will produce compilation error:  'input_sizes' does not name a type.
This is because input_sizes must be assigned inside a context of a function in c++, right ?
std::vector<int> input_sizes;
input_sizes.push_back(sizeof(float));
input_sizes.push_back(sizeof(double));
gr_sync_block("my block", gr_make_io_signaturev(2, 2, input_sizes), gr_make_io_signature(1, 1, sizeof(float)))
Source:  http://gnuradio.org/redmine/projects/gnuradio/wiki/BlocksCodingGuide#IO-signatures


My code (which produce error) is below.

[code]
/* -*- c++ -*- */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <gr_io_signature.h>
#include <vector>
#include <complex>
#include "sample_and_hold_cc_impl.h"

namespace gr {
  namespace howto {

    sample_and_hold_cc::sptr
    sample_and_hold_cc::make()
    {
      return gnuradio::get_initial_sptr
        (new sample_and_hold_cc_impl());
    }

    /*
     * The private constructor
     */

    std::vector <int> xx;
    xx.push_back(25);
    xx.push_back( sizeof( float ) );
    xx.push_back( sizeof( std::complex<float> ) );

    sample_and_hold_cc_impl::sample_and_hold_cc_impl()
      : gr_sync_block("sample_and_hold_cc",
              gr_make_io_signature(<+MIN_IN+>, <+MAX_IN+>, sizeof(<+ITYPE+>)),
              gr_make_io_signature(<+MIN_OUT+>, <+MAX_OUT+>, sizeof(<+OTYPE+>)))
    {}

    /*
     * Our virtual destructor.
     */
    sample_and_hold_cc_impl::~sample_and_hold_cc_impl()
    {
    }

    int
    sample_and_hold_cc_impl::work(int noutput_items,
              gr_vector_const_void_star &input_items,
              gr_vector_void_star &output_items)
    {
        const <+ITYPE+> *in = (const <+ITYPE+> *) input_items[0];
        <+OTYPE+> *out = (<+OTYPE+> *) output_items[0];

        // Do <+signal processing+>

        // Tell runtime system how many output items we produced.
        return noutput_items;
    }

  } /* namespace howto */
} /* namespace gr */
[/code]

reply via email to

[Prev in Thread] Current Thread [Next in Thread]