trouble compiling template class in linux
trouble compiling template class in linux
when I compile my template class in Windows using MinGW, everything works fine, when I compile the same exact thing in Linux, g++ complains wherever I allocate new memory...
any ideas?
any ideas?
Code: Select all
template <typename T> class List{
private:
class Node{
public:
Node *next, *prev;
T data;
Node(const T& d, Node* n = 0, Node* p = 0):data(d),next(n),prev(p){};
};
Node *head, *tail;
public:
List<T>(const T&);
};
template <typename T> List<T>::List(const T& d){
head = tail = new Node(d);
}
Code: Select all
In constructor "List<T>::Node::Node(const T&, List<T>::Node*, List<T>::Node*)[with T = int]':
instantiated from "List<T>::List(const T&)[with T = int]'
Code: Select all
#include "list.h"
int main(){
List<int> m_list(5);
return 0;
}
???????????
Errr... that's not an error - usually you get the "in ... " bit, the "instantiated from ..." bit, then the actual error bit!!In constructor "List<T>::Node::Node(const T&, List<T>::Node*, List<T>::Node*)[with T = int]':
instantiated from "List<T>::List(const T&)[with T = int]'
Care to elaborate further?
yea, i guess i'm just getting a lot of warnings, the seg fault was unrelated.
geez though, i wish i could turn the compiler down from "super-paranoid" to "normal", hehe
isn't there an option like -permissive or something like that?
right now i'm only compiling w/ -Wall and -Wextra, anything else i can do to relax things a bit?
geez though, i wish i could turn the compiler down from "super-paranoid" to "normal", hehe
isn't there an option like -permissive or something like that?
right now i'm only compiling w/ -Wall and -Wextra, anything else i can do to relax things a bit?
'w/' is 'with', right? Last time I checked -Wall and -Wextra turned on warnings. It doesn't turn them off.dudeman wrote:right now i'm only compiling w/ -Wall and -Wextra, anything else i can do to relax things a bit?
I would suggest you keep them on, however, even if they are annoying at times.
C8H10N4O2 | #446691 | Trust the nodes.
Hi,
I tend to compile with -Werror so I can't go on unless all warnings are fixed. Have a look at the Makefile tutorial by Solar. There is a long list of -W flags which you can use. I tend to use all the ones applicable to C++. As suggested in the article, make sure you enable them one at a time!
Cheers,
Adam
I tend to compile with -Werror so I can't go on unless all warnings are fixed. Have a look at the Makefile tutorial by Solar. There is a long list of -W flags which you can use. I tend to use all the ones applicable to C++. As suggested in the article, make sure you enable them one at a time!
Cheers,
Adam