-
compiling discrepencies
this is driving me crazy
in devc++ i'm NOT creating a project. I'm compiling w/ -ansi -pedantic -Wall -Wextra -Werror
if i have a class in a header file like so:
Code:
template <typename T> class myClass
{
public:
myClass();
...
};
and define the constructor in a source file like so:
Code:
template <typname T> myClass<T>::myClass<T>()
{
...
};
it works just fine.
But when I compile the same stuff in cygwin w/the same options, it tells me I have undefined references to my constructors.
WTF???
-
BTW, here's my makefile for gcc:
Code:
COMPILECPP=g++
FLAGS=-g -DDEBUG -ansi -Wall -Wextra -pedantic -Werror
CPPSRC=$*.cpp
BUILDCPP=$(COMPILECPP) $(FLAGS)
BUILDMAINCPP=$(BUILDCPP) -o
.SUFFIXES:
.SUFFIXES: .c .cpp .h .o
.cpp.o: ; $(BUILDCPP) -c $(CPPSRC)
all: List
clean:
rm -rf *.o a.out
List: Driver.o List.o SysCalls.o
$(BUILDMAINCPP) List Driver.o List.o SysCalls.o
SysCalls.o: SysCalls.cpp SysCalls.h
List.o: List.cpp List.h
Driver.o: Driver.cpp List.h SysCalls.h
-
-
oh oh oh OK. yea i've heard that before. because *templates* aren't treated the same as
a *non-templated* class. you're the coolest!
-
so the whole:
Code:
template <typename T> myClass<int>::myClass<int>();
acts as a prototype of sorts?