Sponsored Content
Full Discussion: Struct as return type
Top Forums Programming Struct as return type Post 302933786 by emily on Monday 2nd of February 2015 09:58:02 AM
Old 02-02-2015
Struct as return type

Hello all,
I am trying to define a function with return type as struct, but seem to be failing.

Error I am receiving is following

Code:
.CC error: prototype for 'RpcHOData L1ITMu::MBLTCollection::getUnassociatedHORpcClusters(double)' does not match any in class 'L1ITMu::MBLTCollection'
 struct RpcHOData L1ITMu::MBLTCollection::getUnassociatedHORpcClusters( double minRpcPhi ) 
                  ^
In file included from .h error: candidate is: L1ITMu::MBLTCollection::RpcHOData L1ITMu::MBLTCollection::getUnassociatedHORpcClusters(double)
      struct RpcHOData  getUnassociatedHORpcClusters( double minDist);

Please find the snippet of the code here:
Code:
in .h file --->

namespace L1ITMu {
  class MBLTCollection {

  public:

    struct RpcHOData {
      std::vector< L1ITMu::TriggerPrimitiveList> In;
      std::vector< L1ITMu::TriggerPrimitiveList> Out;
      std::vector< L1ITMu::TriggerPrimitiveList> ho;
    };

}

in CC file --->

struct RpcHOData L1ITMu::MBLTCollection::getUnassociatedHORpcClusters( double minRpcPhi )
{
 .....
 ......
}


Any piece of suggestions would be great.

Thanks in advance,
emily

---------- Post updated at 09:44 AM ---------- Previous update was at 09:40 AM ----------

I forgot to add,
I also tried removing the keyword 'struct' in the return type, did not help either.

Code:
in CC file --->

 RpcHOData L1ITMu::MBLTCollection::getUnassociatedHORpcClusters( double minRpcPhi )
{
 .....
 ......
}

error is then:
Code:
.CC error: 'RpcHOData' does not name a type
 RpcHOData L1ITMu::MBLTCollection::getUnassociatedHORpcClusters( double minRpcPhi )

---------- Post updated at 09:58 AM ---------- Previous update was at 09:44 AM ----------

resolved..Smilie Smilie

the issue was the scope in ,cc file
 

8 More Discussions You Might Find Interesting

1. Programming

Help - Cast converts default int return type

What does the warning message 724 "Cast converts default int return type to." tell me. I am new to C. (used it some in college). We are migrating our c-code to 10.2.0.3.0. The programs compiled clean. However there were several warning messages that kick out. The most prominent warning is: ... (5 Replies)
Discussion started by: rtgreen
5 Replies

2. Programming

array type has incomplete element type

Dear colleagues, One of my friend have a problem with c code. While compiling a c program it displays a message like "array type has incomplete element type". Any body can provide a solution for it. Jaganadh.G (1 Reply)
Discussion started by: jaganadh
1 Replies

3. Shell Programming and Scripting

Find command return type

Hi all does find command return anything if the file to be searched is not found? Like if I search from a file in a dir does it return false or null if the file is not found? Please suggests. (3 Replies)
Discussion started by: Veenak15
3 Replies

4. UNIX for Dummies Questions & Answers

How to access a struct within a struct?

Can someone tell me how to do this? Just a thought that entered my mind when learning about structs. First thought was: struct one { struct two; } struct two { three; } one->two->three would this be how you would access "three"? (1 Reply)
Discussion started by: unbelievable21
1 Replies

5. Shell Programming and Scripting

what is the default return type of localtime() in perl?

Hi, I have given like this to get the time of the sub routine. my $start = localtime(); print "\n start time: $start \n"; Output start time: Fri Apr 29 01:01:31 2011 I want to know what is the format of the time. I am not able to follow is is HH:MM:SS or MM:HH:SS os... (2 Replies)
Discussion started by: vanitham
2 Replies

6. HP-UX

struct utsname throwing error : Value too large to be stored in data type

Hi, I am trying to fetch sysname and nodename using struct utsname. I have two HP-UX servers on with 10 characters and other with 13 characters host name. For the first one I am getting truncated 8 characters as output but for the second one i am getting "Value too large to be stored in data type"... (1 Reply)
Discussion started by: shivarajbm
1 Replies

7. Programming

Problem with implementing the times() function in C (struct tms times return zero/negative values)

Hello, i'm trying to implement the times() function and i'm programming in C. I'm using the "struct tms" structure which consists of the fields: The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process. The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies

8. Programming

Storing C++-struct in file - problem when adding new item in struct

Hi, I have received an application that stores some properties in a file. The existing struct looks like this: struct TData { UINT uSizeIncludingStrings; // copy of Telnet data struct UINT uSize; // basic properties: TCHAR szHost; //defined in Sshconfig UINT iPortNr; TCHAR... (2 Replies)
Discussion started by: Powerponken
2 Replies
Struct(3)						User Contributed Perl Documentation						 Struct(3)

NAME
Inline::Struct -- Manipulate C structures directly from Perl. SYNOPSIS
use Inline C => Config => Structs => ['Foo']; my $obj = Inline::Struct::Foo->new; $obj->num(10); $obj->str("Hello"); myfunc($obj); __END__ __C__ struct Foo { int num; char *str; }; void myfunc(Foo *f) { printf("myfunc: num=%i, str='%s' ", f->num, f->str); } This complete program prints: myfunc: num=10, str='Hello' DESCRIPTION
Inline::Struct is not a new language. It's a language extension designed to be used by Inline::C. It parses struct definitions and creates typemaps and XS code which bind each struct into a Perl class. This code is passed to Inline::C, which compiles it in the normal way. NOTE: Inline::Struct parses only C-style structs. It doesn't know about any C++ extensions to structs like scopes, constructors or methods. If you want such functionality you should use Inline::CPP to parse your structs. Using Inline::Struct Inline::Struct has a Parse::RecDescent grammar to parse C structs. If a struct is recognized, it can be bound to Perl. If the struct's definition is not recognized (usually because it has a member with no typemap), it will not be bound to Perl, but will be available from other functions in C or C++. The following example shows how a simple struct might look to a Perl programmer. Example 1: use Inline C => <<'END', ENABLE => 'STRUCTS'; struct Fraction { long numer; long denom; }; END my $o = Inline::Struct::Fraction->new(4, 3); print $o->numer, $o->denom, " "; $o->numer(4)->denom(7); After the code above has been compiled, Perl's namespace looks a lot like the following: package Inline::Struct::Fraction; sub new { } sub DESTROY { } sub _KEYS { } sub _VALUES { } sub _HASH { } sub numer { } sub denom { } Note that these are actually XS subs written in C, not Perl subs. But that's what it looks like. The Struct Interface The following sections define the interface of each subroutine. Note: this interface is likely to change in future versions of Inline::Struct. Please don't rely on Inline::Struct in production code quite yet. When a struct is bound by Inline::Struct, a new namespace is created underneath Inline::Struct. So if you have a struct named 'Foo', the package of the Perl class will be 'Inline::Struct::Foo'. new If no arguments are provided, all fields are zeroed out. If you provide values, they should be appropriate for the field type, and in the same order as they are defined in the struct. DESTROY The destructor. Should never be called by the programmer -- this is called automatically when the Perl variable holding the struct is destroyed. Frees the memory associated with the struct. If the struct holds pointers to malloc'd memory, they will not be freed. If you run into such a situation, consider using C++ and Inline::CPP instead. _KEYS A read-only method, this returns a reference to an array containing the names of the fields in the struct. The fields are in the order they appear in the C source code. _VALUES A read-only method, this returns a reference to an array containing the values of the fields in the struct. The values are returned in the same order as the fields. _HASH A read-only method, this returns a reference to a hash, mapping field names to field values. Accessors For each field in the struct, an accessor sub will be created which lets you get or set the value in the struct. If no arguments are provided, the sub returns the value of that field. If any arguments are provided, the field is set to the first argument, and the modified structure is returned. This makes setting multiple fields easy: $o->field1(something)->field2(somethingelse); C and C++ Configuration Options Inline::Struct has no configuration options of its own, but it does provide a new configuration option for C or C++. STRUCTS Specifies that structs are to be bound to Perl. There are several meanings to this option, so I'll explain with an example: use Inline C => Config => STRUCTS => 'Foo'; Adds 'Foo' to the list of structs to bind to Perl. use Inline C => Config => STRUCTS => ['Foo', 'Bar']; Adds 'Foo' and 'Bar' to the list of structs to bind to Perl. use Inline C => Config => STRUCTS => undef; Clears the list of structs to bind to Perl. use Inline C => Config => ENABLE => 'STRUCTS'; or use Inline C => Config => STRUCTS => 1; Enable binding structs to Perl, without specifying any structs to search for. As shown, this would bind all structs to Perl. use Inline C => Config => DISABLE => 'STRUCTS'; or use Inline C => Config => STRUCTS => 0; Disable binding structs to Perl. SEE ALSO
For more information about using C from Perl, see Inline::C. For more information about using C++ from Perl, see Inline::CPP. AUTHOR
Neil Watkiss (NEILW@cpan.org) COPYRIGHT
Copyright (C) 2001, Neil Watkiss. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. (see http://www.perl.com/perl/misc/Artistic.html) perl v5.18.2 2001-05-13 Struct(3)
All times are GMT -4. The time now is 04:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy