473,791 Members | 2,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1773
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.co m...
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.Zhan g 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
2314
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 does. I had a closer look at the html source and discovered a lot of Javascript, including Cookies. My suspicion is that the Javascript code needs to be executed for the page to work properly. Also I don't know how liburl deals with Cookies, but
5
1915
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 <% curr="SEK" %> <html>
0
1517
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 Development machine. (Win2003 IIS6) Though now that we have posted it to the Production server we cant seems to upload small files. The Production machine is a Win2000 IIS5 machine. It can take large files just fine. The Small files are what...
1
2195
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 base Classes in .NET make writing a Windows Service Easy" says it should be there. What could be wrong ??? I have the service installer components - added but that interface to add those components is different. Thanks
6
5075
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 MailMessage(); mailMsg.From = from; from = from + from;
7
2431
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 DLL_PROCESS_DETACH, but I can't do this when touching managed code, even if its just calling "delete someObject;". Any recommendations on how to free this object (it needs to be freed when the dll is being unloaded from its caller). Since the CRT is...
3
3863
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. Anyone have any ideas? While rdz.Read() lb(rdz("id")) = New Button lb(rdz("id")).ID = "lb" & rdz("id") lb(rdz("id")).Text = rdz("lloyds_num") AddHandler lb(rdz("id")).Click, AddressOf dayclickz
0
1724
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 in IIS but I can't run any ASP.NET pages. Everything in IIS was configured to handle the .aspx file extension by the .NET framework installation and it installed with no errors. When I try to view a simple ASP.NET page through a web browser I...
1
2141
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 from the Office XP suite on a pentium 4 running WinXP Home. We have a database which has been running successfully for approx 12 months now. Suddenly when I tried to generate a report or query using a wizard I get the mssg "Active X cant create...
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.