1

I have some own made headers but whenever I use them with "stdafx.h", vs throw multiple defined symbols error for the function defined in the headers,

stdafx.h be like:

#include <stdio.h>
#include <tchar.h>

#include "pUtils.h"
#include "pString.h"
#include "PodVector.h"

let's say I have a function defined in PodVector.h as test_PodVector()

then i got error like:

error LNK2005: "void __cdecl test_PODVector(void)" (?test_PODVector@@YAXXZ) already defined in ar.obj 1>ar.exe : fatal error LNK1169: one or more multiply defined symbols found

my main cpp file is like

#include "stdafx.h"

using namespace std;

int main() {    PodVector<int> vec;

    return 0; }

the errors go away if I make those functions static but why?

unknown.prince
  • 710
  • 6
  • 19

0 Answers0