* Templates and Linking
@ 1997-08-29 4:08 Mike Legg
0 siblings, 0 replies; only message in thread
From: Mike Legg @ 1997-08-29 4:08 UTC (permalink / raw)
To: gnu-win32
[-- Attachment #1: Type: text/plain, Size: 420 bytes --]
Hi,
Does anyone know how to get around this error which is reported during
linking when using the STL:
Table.o(.data+0xc):Table.cc: multiple definition of
`__default_alloc_template<false, 0>::free_list'
Main.o(.data+0x0):Main.cc: first defined here
The exact same code compiles fine on gcc2.7.2 with djgpp. Is there any
reason why template intansiation is different?
Attached is a trivial example.
regards,
Mike.
[-- Attachment #2: Main.cc --]
[-- Type: text/x-c, Size: 187 bytes --]
#include <string>
#include "Table.h"
int
main(int argc, char** argv)
{
Table table("Command Line Arguments");
for (int i=0; i<argc; table.add(argv[i++]));
table.output();
}
[-- Attachment #3: Table.cc --]
[-- Type: text/x-c, Size: 365 bytes --]
#include <list>
#include <string>
#include <iostream.h>
#include "Table.h"
Table::Table(const string& t): title(t) {}
void
Table::add(const string& elem)
{
table.push_back(elem);
}
void
Table::output()
{
cout << "Table: " << title << endl;
for (TableType::iterator i = table.begin(); i != table.end(); i++)
cout << (*i) << endl;
}
[-- Attachment #4: Table.h --]
[-- Type: text/x-c++, Size: 306 bytes --]
#ifndef TABLE_H
#define TABLE_H
#include <list>
#include <string>
#include <iostream.h>
class Table
{
typedef list<string> TableType;
TableType table;
string title;
public:
Table(const string& t);
void add(const string& elem);
void output();
};
#endif TABLE_H
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-08-29 4:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-29 4:08 Templates and Linking Mike Legg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).