Re: how to pass smart pointes to function.

From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 07/08/04


Date: Thu, 08 Jul 2004 20:20:49 GMT

lokb wrote:
> I have a structure which and defined a smart pointer to the structure.
>
> /* Structure of Begin Document Index Record */
> typedef struct BDI_Struct{
> unsigned char rname;
> unsigned short int rlen;
> int code;
> short int reserved;
> char indexName[9];
> unsigned char tripLen;
> unsigned char tripCode;
> TRIPLET01 t01;
> }BDIStruct;
>
> /* Structure of Index Element Record */
> typedef struct record{
> unsigned char rname;
> unsigned short int rlen;
> int code;
> short int reserved;
> unsigned char tripLen;
> unsigned char tripCode;
> union
> {
> TRIPLET01 t01;
> TRIPLET57 t57;
> TRIPLET2D t2D;
> TRIPLET36 t36;
> TRIPLET02 t02;
> TRIPLET80 t80;
> TRIPLETGEN tgen;
> }TRec;
> }IndexStruct;
>
> Defined the smart pointer as below:
> where ObjVar returns the pointer.
> typedef ObjVar<IELStruct> IELStruct_sptr;

What's "IELStruct"? What's ObjVar? I can only see the definitions
of "BDIStruct", "BDI_Struct", "IndexStruct", and "record". No other
types have been defined in the global namespace.

> typedef ObjVar<BDIStruct> BDIStruct_sptr;
>
> Now when i am passing the smart pointers to the function i get compilation
> errors
> I am passing the smart pointers as
>
> int vValidateIndModcaFile(ObjVar<BDIStruct>& bdirec,ObjVar<IndexStruct>&
> ielrec);
>
> Is it the right way to pass the smart pointers.
>
> Could you plz guide me.
>
> I am getting the erros like
>
> "/vpapp/accenture/ISIXRelease1206302004/include/sptr.hpp", line 68.11:
> 1540-1101 (W) A return value of type "BDI_Struct *" is expected.

That seems to be a warning "(W)". And you haven't provided the code
in 'sptr.hpp' so that we could see why the warning is given.

> "/vpapp/accenture/ISIXRelease1206302004/include/sptr.hpp", line 63.12:
> 1540-0700 (I) The previous message was produced while processing
> "ObjVar<BDI_Struct>::operator->()".

It seems that

    ObjVar<BDI_Struct>::operator->()

does not return BDI_Struct*, but instead returns something else
that compiler doesn't like.

> "IndOutModcaParser.cpp", line 1814.5: 1540-0700 (I) The previous message
> was produced while processing
> "CIndOutModcaParser::vValidateIndModcaFile(ObjVar<BDI_Struct> &,
> ObjVar<record> &)".
> "/vpapp/accenture/ISIXRelease1206302004/include/sptr.hpp", line 68.11:
> 1540-1101 (W) A return value of type "record *" is expected.

Same thing here. We'd need to see the line 68.11 of 'sptr.hpp'.

> "/vpapp/accenture/ISIXRelease1206302004/include/sptr.hpp", line 63.12:
> 1540-0700 (I) The previous message was produced while processing
> "ObjVar<record>::operator->()".

This again seems to indicate that the template's operator-> does
not return what is expected of it.

> "IndOutModcaParser.cpp", line 1814.5: 1540-0700 (I) The previous message
> was produced while processing
> "CIndOutModcaParser::vValidateIndModcaFile(ObjVar<BDI_Struct> &,
> ObjVar<record> &)"

The declaration of the 'vValidateIndModcaFile' function is not to
blame. More likely the 'ObjVar' template is not up to par with what
the compiler expects from it.

Victor



Relevant Pages

  • how to pass smart pointes to function.
    ... typedef struct BDI_Struct{ ... unsigned short int rlen; ... unsigned char tripLen; ... Now when i am passing the smart pointers to the function i get compilation ...
    (comp.lang.cpp)
  • [EXPL] Windows SMB Nuker
    ... unsigned char error_class; ... int len; ... negotiate_protocol (unsigned char *buffer, int fd) ...
    (Securiteam)
  • Re: access violation
    ... I didn't find any access violation on running your code in VC 6.0 compiler. ... typedef struct tagTIMESTAMP_STRUCT ... unsigned int fraction; ... > unsigned char u8; ...
    (microsoft.public.vc.language)
  • Re: how to pass smart pointes to function.
    ... > typedef struct BDI_Struct{ ... > unsigned short int rlen; ... > unsigned char tripLen; ...
    (comp.lang.cpp)
  • [NT] Ipswitch Instant Messaging Multiple Vulnerabilities
    ... unsigned char key) ... des_crypt_ecb(ctx, output, output); ... int tcp_recv(int sd, u8 *buff, int len); ...
    (Securiteam)