qualified name is not allowed

H

hyderabadblues

using namespace std;

typedef struct
{
tU16 u16AppID;
tU16 u16RegisterID;
tU16 u16CmdCounter;
tU16 u16FunctionID;
tU16 u16SourceSubID;
tU32 u32InternalData;
} trMessageDataForMethodResult;

class ExecuteTest
{
auto_ptr< trMessageDataForMethodResult >
_MessageDataForMethodResultExecuteTest;
};

I am using RVCT compiler( ARM )
 
H

hyderabadblues

I forgot to paste the problem,
While executing following code( I have removed code that Im not
suppossed to post).I am getting the error as qualified name is not
allowed at the line where an object of auto_ptr is declared.Can some
tell me what is the problem
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

using namespace std;

typedef struct
{
tU16 u16AppID;
tU16 u16RegisterID;
tU16 u16CmdCounter;
tU16 u16FunctionID;
tU16 u16SourceSubID;
tU32 u32InternalData;

} trMessageDataForMethodResult;

class ExecuteTest
{
auto_ptr< trMessageDataForMethodResult >
_MessageDataForMethodResultExecuteTest;

};

I am using RVCT compiler( ARM )

I don't know if this is the problem (since my slightly modified
version compiles just fine on VC++8) but in C++ you normally declare a
struct like this:

struct Name
{
int members;
};

with no typedefs.
 
H

hyderabadblues

I don't know if this is the problem (since my slightly modified
version compiles just fine on VC++8) but in C++ you normally declare a
struct like this:

struct Name
{
int members;

};

with no typedefs.

I have also tried changing the structure declatration. but it didnt
worked
 
P

peter koch

using namespace std;

typedef struct
{
tU16 u16AppID;
tU16 u16RegisterID;
tU16 u16CmdCounter;
tU16 u16FunctionID;
tU16 u16SourceSubID;
tU32 u32InternalData;

} trMessageDataForMethodResult;

class ExecuteTest
{
auto_ptr< trMessageDataForMethodResult >
_MessageDataForMethodResultExecuteTest;

};

I am using RVCT compiler( ARM )

I don't have an answer, but the only problem (from a legal point of
view) I can see with this code is the use of a reserved name for the
struct. I assume that tU16 and tU32 are proper names.
Well... right now I see that you haven't qualified auto_ptr. Don't you
believe that this should be std::auto_ptr?

/Peter
 
V

Victor Bazarov

This is a reserved identifier. You're not supposed to use it.
I have also tried changing the structure declatration. but it didnt
worked

FAQ 5.8. Please read it. You will understand (hopefully) why we
do not like to guess [whether you included <memory>, whether you
have other macros that change the actual code, etc.]

V
 
V

Victor Bazarov

peter said:
I don't have an answer, but the only problem (from a legal point of
view) I can see with this code is the use of a reserved name for the
struct. I assume that tU16 and tU32 are proper names.
Well... right now I see that you haven't qualified auto_ptr. Don't you
believe that this should be std::auto_ptr?

I am guessing you didn't see the "using" directive up on top...

V
 
F

Fei Liu

hyderabadblues said:
using namespace std;

typedef struct
{
tU16 u16AppID;
tU16 u16RegisterID;
tU16 u16CmdCounter;
tU16 u16FunctionID;
tU16 u16SourceSubID;
tU32 u32InternalData;
} trMessageDataForMethodResult;

class ExecuteTest
{
auto_ptr< trMessageDataForMethodResult >
_MessageDataForMethodResultExecuteTest;
};

I am using RVCT compiler( ARM )
auto_ptr is used in the context of RAII, in this case there is no
resource allocated and acquired at all. I would check if that's the
cause of the error you see.
 
S

Salt_Peter

I have also tried changing the structure declatration. but it didnt
worked

First, auto_ptr doesn't exist, you need to #include <memory> and then
use std::auto_ptr.
Then, any identifier that uses an underscore + a capital letter is
implementation reserved.
So _MessageDataForMethodResultExecuteTest is just begging for
problems.

See if you can follow the following code as a guide:

#include <iostream>
#include <memory>

struct N
{
N(int n) : m_n(n) { std::cout << "N()\n"; }
~N() { std::cout << "~N()\n"; }
int get() const { return m_n; }
private:
int m_n;
};

class Test
{
std::auto_ptr< N > ap;
public:
Test(int r) : ap( new N(r) )
{
std::cout << "Test()\n";
}
~Test() { std::cout << "~Test()\n"; }
int get() const { return ap->get(); }
private:
Test(const Test& copy); // disabled
};

int main()
{
Test instance(99);
std::cout << instance.get() << std::endl;
}

/*
N()
Test()
99
~Test()
~N()
*/
 
H

hyderabadblues

I don't have an answer, but the only problem (from a legal point of
view) I can see with this code is the use of a reserved name for the
struct. I assume that tU16 and tU32 are proper names.
Well... right now I see that you haven't qualified auto_ptr. Don't you
believe that this should be std::auto_ptr?

/Peter

I have an initial declaration using namespace std
 
H

hyderabadblues

auto_ptr is used in the context of RAII, in this case there is no
resource allocated and acquired at all. I would check if that's the
cause of the error you see.

It is a member variable, I will initialize it in the actual class
definition.
 
H

Howard

hyderabadblues said:
I have an initial declaration using namespace std

Not related to your problem, but if this is in a header file, then it's not
a great idea to do that. You're forcing every file that uses this header to
bring in the entire std namespace. It's preferred to either use
"std::auto_ptr", or to use "using std::auto_ptr".

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top