A Small Error, A Big Annoyance

closed account (zb0S216C)
I'm receiving this error:
Expected a declaration

It's not the most helpful error message in the world, I know, but that's the only error I'm receiving. I know that this type of error occurs when a right parenthesis is missing, a closing brace is missing, a semi-colon is missing, or when a comma is missing. I can't seem to find any of these signs.

This is the code block that gives me the error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
template < typename __Typename__ >
ERRORCODERETURN StaticEntryBlock < __Typename__ >::eAssemble( const __Typename__ &rObject )
{
    switch( this->_BlockInfo._eActiveState )
    {
        case ACTIVESTATE_ACTIVE:
	     return ERRORCODERETURN( EC_FAILED, "Entry in use" );

	case ACTIVESTATE_INACTIVE:
	     try
	     {
	         // Attempt to allocate the resource block.
	         this->_BlockInfo._pResource = ( new __Typename__( rObject ) );
		 this->_BlockInfo._eActiveState = ACTIVESTATE_ACTIVE;
		 return ERRORCODERETURN( EC_SUCCESS, "Successful assembly" );
	     }

	     catch( std::bad_alloc )
	     {
	         this->_BlockInfo._pResource = NULL;
		 this->_BlockInfo._eActiveState = ACTIVESTATE_INACTIVE;
		 return ERRORCODERETURN( EC_BAD_ALLOC, "Bad allocation" );
	     }
	     break;
    }
}


This is the declaration of eAssemble( ):

 
ERRORCODERETURN eAssemble( const __Typename__ &rObject );

Can you see what might be causing the error? I can't.

Wazzak
Last edited on
Check the block just before.
closed account (zb0S216C)
I don't think that's the source, Helios. Here's all of the blocks in the same file, if it helps:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
template < typename __Typename__ >
StaticEntryBlock < __Typename__ >::StaticEntryBlock( void )
{
    this->_BlockInfo._pResource = NULL;
    this->_BlockInfo._eActiveState = ACTIVESWITCH_ACTIVE;
}

template < typename __Typename__ >
StaticEntryBlock < __Typename__ >::~StaticEntryBlock( void )
{
    vDisassemble( );
}

template < typename __Typename__ >
SWITCH_ACTIVESTATE StaticEntryBlock < __Typename__ >::eReturnActiveState( void ) const
{
    return this->_BlockInfo._eActiveState;
}


Wazzak
Last edited on
What line is the error pointing to?
closed account (zb0S216C)
Well, VCE is highlight both this's and the return statement in the try block.

Wazzak
i'm receiving this error:
Expected a declaration


Don't paraphrase errors. Post the error in its entirety. There's no way that's all it's telling you.

Well, VCE is highlight both this's and the return statement in the try block.


So you're getting the same error 3 times? Once for each of those lines?
The function appears to not return a value in all cases (logical paths.)

Line 13: new __Typename__( rObject ) assumes that __Typename__ has a public copy constructor.

Line 18: catch( std::bad_alloc ) perhaps try catch( std::bad_alloc &e )
closed account (zb0S216C)
Disch wrote:
Don't paraphrase errors. Post the error in its entirety. There's no way that's all it's telling you.

Allow me explain what my situation, and me error is, properly. When I hover over the underlined sections of the code, it says: Expected a declaration. However, when I compile the project( as a static library ), I get not errors or warnings.

See the image of my VCE[1], then you'll know what I'm on about.

Mathhead, I've always called an object constructor when using new/new[ ], and it never caused problems. Also, I've always used std::bad_alloc, which never caused problems either.

References:
[1]http://postimage.org/image/5ohdv0k/

Wazzak
Last edited on
You have 2 return statements in your try/catch block. So is the "break" actually reached?
closed account (zb0S216C)
mcrist wrote:
You have 2 return statements in your try/catch block. So is the "break" actually reached?

Probably not. I never realized it as I was dog tired when I wrote the code. I'll remove it now. Thanks for the heads up, anyway.

Wazzak
Oh, for fu- Why are you wasting our time with this? If the compiler says it's fine, then it's fine. Period.
The highlighter probably got confused while parsing, or forgot to update at some point.
Topic archived. No new replies allowed.