473,386 Members | 1,908 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,386 software developers and data experts.

gcc cant support this ??

the following code:

template <class T>
class test{
typedef T::XXX x;
};

int main(){
return 0;
}
Cant be compiled by mingw (but can by borland c++ 5.5) .
Cant gcc support this ?


May 21 '06 #1
7 1753
William.Zhang wrote:
template <class T>
class test{
typedef T::XXX x;
};

int main(){
return 0;
} Cant be compiled by mingw (but can by borland c++ 5.5) .
Cant gcc support this ?


What error message do you get? What line does it point to?

I don't fully understand 'typename', but you can try that instead of
'class'...

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
May 21 '06 #2
William.Zhang wrote:
the following code:

template <class T>
class test{
typedef T::XXX x;
change to typedef typename T::XXX x;
};

int main(){
return 0;
}
Cant be compiled by mingw (but can by borland c++ 5.5) .
Cant gcc support this ?

In my opinion, it shouldn't be compiling an unused template...

--
Ian Collins.
May 21 '06 #3
William.Zhang wrote:
the following code:

template <class T>
class test{
typedef T::XXX x;
This should read:

typedef typename T::XXX x;

The compiler is not entitled to assume that T::XXX is a typename, so it has
to be told.
};

int main(){
return 0;
}
Cant be compiled by mingw (but can by borland c++ 5.5) .
Cant gcc support this ?


Your code is in error, g++ is correct.
Best

Kai-Uwe Bux
May 21 '06 #4

Ian Collins wrote:
William.Zhang wrote:

Cant be compiled by mingw (but can by borland c++ 5.5) .
Cant gcc support this ?

In my opinion, it shouldn't be compiling an unused template...


Yeah, that's a pretty serious violation of the standard.

May 21 '06 #5
this is OK:
typedef typename T::XXX x;

gcc is strict to c++.

"Phlip" <ph******@yahoo.com> дÈëÏûÏ¢ÐÂÎÅ:JC*******************@newssvr21.news. prodigy.com...
William.Zhang wrote:
template <class T>
class test{
typedef T::XXX x;
};

int main(){
return 0;
}

Cant be compiled by mingw (but can by borland c++ 5.5) .
Cant gcc support this ?


What error message do you get? What line does it point to?

I don't fully understand 'typename', but you can try that instead of
'class'...

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!

May 22 '06 #6

Noah Roberts wrote:
Ian Collins wrote:
William.Zhang wrote:

Cant be compiled by mingw (but can by borland c++ 5.5) .
Cant gcc support this ?

In my opinion, it shouldn't be compiling an unused template...


Yeah, that's a pretty serious violation of the standard.


Instantiating it would be a violation. Compiling it is mandatory. This
is the reason
we talk about two-phase name lookup for templates, in both phases name
lookup
happens. 'typename' is needed here (as others have shown) because it
tells the
compiler in phase 1 (compilation) what the results of phase 2
(instantiation) will be.

HTH,
Michiel Salters

May 22 '06 #7
Mi*************@tomtom.com wrote:
Noah Roberts wrote:
Ian Collins wrote:
William.Zhang wrote:

Cant be compiled by mingw (but can by borland c++ 5.5) .
Cant gcc support this ?
In my opinion, it shouldn't be compiling an unused template...


Yeah, that's a pretty serious violation of the standard.

Instantiating it would be a violation. Compiling it is mandatory. This
is the reason
we talk about two-phase name lookup for templates, in both phases name
lookup
happens. 'typename' is needed here (as others have shown) because it
tells the
compiler in phase 1 (compilation) what the results of phase 2
(instantiation) will be.

Can you point me at the appropriate part of the standard? I've never
been 100% sure what the compiler should do with unused templates, beyond
checking they are well formed.

--
Ian Collins.
May 22 '06 #8

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

Similar topics

2
by: Uwe Mayer | last post by:
Hi, I want do use liburl to scan a webpage which is only accessible from within my LAN environment. While mozilla manages to load the target URL properly neither wget, nor liburl or liburl2...
5
by: Lasse Edsvik | last post by:
can you guys please tell me why i cant use currency as a name in my querystring? note: i NEED to use it since i'll be linking to a remote site were they get that info from querystring <%...
0
by: Scott Townsend | last post by:
We are trying to get the Microsoft ASPFileUpload to work on both Win2003 and Win2000 http://support.microsoft.com/default.aspx?scid=kb;en-us;q299692 We can now get large and small files on our...
1
by: andrewcw | last post by:
I am building the basic windows service, but on my tool box tab , there are no components, just clipboard Ring,l pointer & general. But the MSDN article Dec 2001 by Getz, "windows services: New...
6
by: erdem kemer | last post by:
i cant send mail to yahoo mail or hotmail while i can send my other mail accounts (pop3) is it becouse yahoo and hotmail is web-based mail here is the code MailMessage mailMsg = new...
7
by: Adam | last post by:
I have a managed cpp wrapper. Im using this in a native dll as a static variable. I need to free this library when the dll is done being used. The perfect place to do this is DllMain for...
3
by: Michael Evanchik | last post by:
Im not getting any error messages but the event is not going off when i click the button it just posts back to the same page. I know this code has worked outside of Calanders with the same code. ...
0
by: Tony Lewis | last post by:
I'm running IIS on a Windows 2k server and have just installed the .NET framework 1.1 so I can deploy ASP.NET applications on my server through .NET Studios. All my normal ASP applications run fine...
1
by: erotikaboi | last post by:
Guys, Firstly let me say I am a photographer so if you can offer me a solution I will really appreciate it in simple english not techiespeak as I wont understand it. Thanks. Ok, I am using Access...
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:
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.