Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7034327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:10:20+00:00 2026-05-28T01:10:20+00:00

I have a header file, that is for a GNU Radio Signal Processing block,

  • 0

I have a header file, that is for a GNU Radio Signal Processing block, and to define a C++ API. As I wrote in the comments it uses a “friend” definition in order to handle Boost Shared Pointers in a secure manner, so that no accidental raw pointers occur (access to private constructors).

I cannot really say why this fails. It seems to be related with the identifiers used at the constructors. The class definitions btw. ends with a “;” 😉

My build error message, is (I marked the lines in question with [point n].

cogra_binary_slicer.h:64:66: error: return type specification for
constructor invalid [point 1]
cogra_binary_slicer.cc: In function
‘cogra_binary_slicer_sptr cogra_binary_slicer()’:
cogra_binary_slicer.cc:42:41: error: expected type-specifier [POINT 2] before
‘cogra_binary_slicer’ cogra_binary_slicer.cc:42:41: error: expected
‘)’ before ‘cogra_binary_slicer’ cogra_binary_slicer.cc:42:63: error:
could not convert ‘gnuradio::get_initial_sptr(T*) with T = int’
from ‘boost::shared_ptr’ to ‘cogra_binary_slicer_sptr {aka
boost::shared_ptr}’

That however narrows it down to three files.

The header, cogra_binary_slicer.h:

#ifndef INCLUDED_COGRA_BINARY_SLICER
#define INCLUDED_COGRA_BINARY_SLICER

#include <cogra_api.h>
#include <gr_block.h>

class cogra_binary_slicer;

typedef boost::shared_ptr<cogra_binary_slicer> cogra_binary_slicer_sptr;

/*!
 * \brief Return a shared_ptr to a new instance of cogra_binary_slicer.
 *
 * To avoid accidental use of raw pointers, cogra_binary_slicer's
 * constructor is private.  cogra_binary_slicer is the public
 * interface for creating new instances.
 */
COGRA_API cogra_binary_slicer_sptr cogra_binary_slicer ();


class COGRA_API cogra_binary_slicer : public gr_block
{
private:
  // The friend declaration allows cogra_binary_slicer to
  // access the private constructor.


  // [POINT 1]
  friend COGRA_API cogra_binary_slicer_sptr cogra_binary_slicer ();

  cogra_binary_slicer ();   // private constructor

 public:
  ~cogra_binary_slicer ();  // public destructor

  // Where all the action really happens

  int general_work (int noutput_items,
            gr_vector_int &ninput_items,
            gr_vector_const_void_star &input_items,
            gr_vector_void_star &output_items);
}; // yes

#endif /* INCLUDED_COGRA_BINARY_SLICER */

cogra_binary_slicer.cc, where the instance is created (which fails). Point of failure marked with [POINT 2]:

#include <cogra_binary_slicer.h>
#include <gr_io_signature.h>

/*
 * Create a new instance of cogra_binary_slicer and return
 * a boost shared_ptr.  This is effectively the public constructor.
 */
cogra_binary_slicer_sptr 
cogra_binary_slicer ()
{
  return gnuradio::get_initial_sptr(new cogra_binary_slicer ()); **[POINT 2]**
}

And the API header, cogra_api.h:

#ifndef INCLUDED_COGRA_API_H
#define INCLUDED_COGRA_API_H

#include <gruel/attributes.h>

#ifdef gnuradio_cogra_EXPORTS
#  define COGRA_API __GR_ATTR_EXPORT
#else
#  define COGRA_API __GR_ATTR_IMPORT
#endif

#endif /* INCLUDED_COGRA_API_H */

I attached that much source because I can’t narrow down why the compilation fails at that specific locs.

Some pointers why my return type is invalid could be helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:10:21+00:00Added an answer on May 28, 2026 at 1:10 am

    Rename your creation function to something other then class name :

    friend COGRA_API cogra_binary_slicer_sptr cogra_binary_slicer ();
    

    Otherwise, the compiler might see it as a constructor with areturn type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a header file, lets say Common.h, that is included in all of
I have a flat-file schema that has a header and detail records. It looks
I have a header file like this: #ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #ifdef _DEBUG //
I have a header file with all the enums listed (#ifndef #define #endif construct
I have this header file, zeeheader.h, and I wrote some classes in it, I'm
I have C++ project (VS2005) which includes header file with version number in #define
I have a C header file that I have precompiled using the gcc -E
I have code in my header file that looks like: typedef struct _bn bnode;
I have a header ( .h ) file that I've defined a bunch of
I have a header file that contains a class. Within that class, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.