473,382 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Help with C++ compile error

Hi,

We have a class that defines an exception:

template <class A, class B, class C, class D class X : public Y
{
...
class SomeException : public BaseException
{
...
}
};

We need to catch the exception in another class:

template <class Dispatcherclass Something : public YetAnotherClass
{
Dispatcher *fDispatcher;

void HandleMessage(...)
{
try {
...
} catch (Dispatcher::SomeException) // This line has the error
{
...
}
}
....

[some code omitted for brevity]

This code compiles under Sun Workshop 6 update 2 and under Compaq C++
V6.5-004 for OpenVMS Alpha V7.3-1 but not under GNU C++ V3.3.5 and
2.95.4 (on debian Linux).

The error message is "parse error before ';' token" on the 'catch'
line.

Can anyone tell me if this is a compiler bug or is the syntax
incorrect?

TIA, Mark

Aug 15 '06 #1
3 1066
Mark wrote:
Hi,

We have a class that defines an exception:

template <class A, class B, class C, class D class X : public Y
{
...
class SomeException : public BaseException
{
...
}
};

We need to catch the exception in another class:

template <class Dispatcherclass Something : public YetAnotherClass
{
Dispatcher *fDispatcher;

void HandleMessage(...)
{
try {
...
} catch (Dispatcher::SomeException) // This line has the error
} catch (typename Dispatcher::SomeException)
{
...
}
}
...

[some code omitted for brevity]

This code compiles under Sun Workshop 6 update 2 and under Compaq C++
V6.5-004 for OpenVMS Alpha V7.3-1 but not under GNU C++ V3.3.5 and
2.95.4 (on debian Linux).

The error message is "parse error before ';' token" on the 'catch'
line.

Can anyone tell me if this is a compiler bug or is the syntax
incorrect?
I think the syntax is correct, but not the semanctics. SomeException is a
name dependand on a template argument. In such a situation, you have to
explicitly tell the compiler that it's a type, otherwise it is required to
assume that it's a value.

Aug 15 '06 #2

Mark wrote:
Hi,

We have a class that defines an exception:

template <class A, class B, class C, class D class X : public Y
{
...
class SomeException : public BaseException
{
...
}
};

We need to catch the exception in another class:

template <class Dispatcherclass Something : public YetAnotherClass
{
Dispatcher *fDispatcher;

void HandleMessage(...)
{
try {
...
} catch (Dispatcher::SomeException) // This line has the error
{
...
}
}
...

[some code omitted for brevity]

This code compiles under Sun Workshop 6 update 2 and under Compaq C++
V6.5-004 for OpenVMS Alpha V7.3-1 but not under GNU C++ V3.3.5 and
2.95.4 (on debian Linux).

The error message is "parse error before ';' token" on the 'catch'
line.
The error is probably a missing "typename" keyword. I would change the
catch line to read:

catch (typename Dispatcher::SomeException)

Greg

Aug 15 '06 #3
On 15 Aug 2006 03:21:33 -0700, "Greg" <gr****@pacbell.netwrote:
>The error is probably a missing "typename" keyword. I would change the
catch line to read:

catch (typename Dispatcher::SomeException)
Thanks Rolf and Greg, that has solved it :-)

Mark
Aug 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jagdeesh | last post by:
Hai Colleagues, I am using Tomcat 4.1.24 and JDK 1.4.0_03 in my winXP machine. I've transferred a set of folders(containing jsp files) into tomcat's webapps directory(to /webapps/bob ,...
5
by: xuatla | last post by:
Hi, I encountered the following compile error of c++ and hope to get your help. test2.cpp: In member function `CTest CTest::operator+=(CTest&)': test2.cpp:79: error: no match for 'operator='...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: bradleyp | last post by:
Hi all, Hopefully somebody can help. In Access 2002-SP2, I receive an error from the VB Editor if I try to compile the following code (see below). The error is as follows: Compile Error:...
4
by: livin | last post by:
my log... INFO urllib.urlopen('http://192.168.1.11/hact/kitchen.asp', urllib.urlencode({'Action': 'hs.ExecX10ByName+Kitchen+Lights%2C+On %2C+100&x=4&y=6'})) INFO INFO File...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
7
by: rn5a | last post by:
This is the second time I am asking this question in this newsgroup since I haven't got a solution or response from anyone in my previous post & I need to resolve this issue desperately. Sorry for...
2
by: Raghunadhan | last post by:
pLS HELP ME HOW THIS ERROR OCCURED . WHEN RUNNING JSP PAGE BY USING TOMCAT APACHE.... org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: -1 in...
9
by: beet | last post by:
Hi, I am really not good at c/c++. Some simple code.. #include <stdio.h> #include <stdlib.h> #include <math.h> #include "simlibdefs.h"
4
by: Marcus | last post by:
you guys are funny. i thought this was comp.lang.c++... not comp.we.can.only.comment.on things.that.can.be.compiled.c++ back in the day in this group, the jibe replies would've looked like:...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.