473,498 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AIX va7 "template dependent name that is not a type must be qualified" warning

1 New Member
On AIX, a template class containing a nested class which needs to be a friend provokes a warning:

(W) A template dependent name that is a type must be qualified with "typename".

and method definitons give this warning:

(S) The class qualifier "List" contains a circular reference back to ""

How can these be avoided?

Following is a complete demo program, which g++ 4.1.1 accepts without complaint.

Thanks to anyone who can help!
Expand|Select|Wrap|Line Numbers
  1. template <class T>
  2. class List {
  3. public:
  4.     List() : m_Head(0) {};
  5.     void Prepend(T item);
  6.  
  7.     // 1540-0152 (W) A template dependent name that 
  8.     // is a type must be qualified with "typename".
  9.     class Iter;
  10.     friend class List<T>::Iter;  // <-- WARNING HERE
  11.  
  12.     //Does not work: friend class List<typename T>::Iter;
  13.     //Does not work: friend typename class List<T>::Iter;
  14.     //Does not work: friend class typename List<T>::Iter;
  15.  
  16.     class Iter {
  17.     public:
  18.       Iter(const List & list);
  19.       bool Done(void);
  20.       T GetCurrent(void);
  21.       void Advance(void);
  22.     private:
  23.       typename List<T>::Link * m_Curr;
  24.     };
  25. private:
  26.     struct Link {
  27.       T value;
  28.       Link *next;
  29.     };
  30.     Link * m_Head;
  31. };
  32.  
  33. // 1540-0100 (S) The class qualifier "List" contains a circular reference back to "".
  34. template <class T> void List<T>::Prepend(T item) { // <--WARNING HERE
  35.   Link *newlink = new Link;
  36.   newlink->value = item;
  37.   if (m_Head == 0) {
  38.     newlink->next = 0;
  39.     m_Head = newlink;
  40.   } else {
  41.     newlink->next = m_Head;
  42.     m_Head = newlink;
  43.   }
  44. };
  45. template<class T> List<T>::Iter::Iter(const List<T> & list)
  46.   : m_Curr(list.m_Head)
  47. { }
  48. template<class T> bool List<T>::Iter::Done(void) { return (m_Curr==0); }
  49. template<class T> T List<T>::Iter::GetCurrent(void) { return m_Curr->value; }
  50. template<class T> void List<T>::Iter::Advance(void) {
  51.   if (m_Curr != 0) { m_Curr = m_Curr->next; }
  52. }
  53.  
  54. #include <iostream>
  55. using namespace std;
  56. int main() {
  57.   typedef List<int> ListOfInt_t;
  58.   ListOfInt_t list;
  59.  
  60.   for (int i=0; i<10; ++i) { list.Prepend(i); }
  61.  
  62.   for (ListOfInt_t::Iter iter(list);
  63.        ! iter.Done();
  64.        iter.Advance())
  65.   {
  66.    cout << "Item: " << iter.GetCurrent() << endl;
  67.   }
  68.  
  69.   return 0;
  70. }
  71.  
Mar 16 '07 #1
0 1406

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5593
by: Liang | last post by:
Hi, I use "defined $r_libs->{$name}" to check first if a key exists in a hash table. But Perl gives a warning WHENEVER the key exists: "Use of uninitialized value". Would u please help to...
0
1851
by: Gianni Mariani | last post by:
I remember seeing a neat template specialization trick posted here a few months ago that allowed the detection of a type containing a member. After a day searching through google archives I come up...
10
1751
by: Lionel B | last post by:
Greetings, I cannot figure out why the following code does not compile: --- BEGIN CODE --- typedef double ftype(double); struct A {
1
1834
by: Mat DeLong | last post by:
Can someone explain this error to me? : main.cpp:9: instantiated from `void show(const LIST::List<T>&) ' main.cpp:23: instantiated from here list.cpp:58: error: dependent-name...
12
4860
by: Charlie Zender | last post by:
Hi, I am unable to compile a large body of code with extremely pedantic compile time checks activate, so that warnings cause errors. With GCC 3.3.1, I do this with gcc -std=c99 -pedantic...
1
1721
by: Jay | last post by:
I'm installing one of my dlls to the GAC but no matter what attribute I try, the name that shows up in explorer under global assembly name is always just the name of my assembly file. Is there a...
6
5242
by: PraZ | last post by:
Hi all. Here is a simple code, which when compiled with gcc results in the warning "incompatible pointer type" for arg 1, as expected. But this is just what I want to do, because it makes it...
1
12305
by: mato81 | last post by:
Hi all! I am a newbie to WSDL. I have a questions which has been driving me crazy... If I would have a WSDL with a types element somewhat like below, what is the point of the third last row...
2
2044
by: Hukkky | last post by:
File : NodeList.h //---------------------------------------------------------------------- #ifndef NODELIST_H #define NODELIST_H #include <string> using std::string; template <typename T>...
0
7125
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
7165
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,...
0
7203
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...
0
5462
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,...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1417
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
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...

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.