-4

I'm working on a little project to try to get the Source Engine 2013 code working under the Qt Creator IDE. My ultimate goal is to turn it into a CMake project to throw out Valve's limited VPC system, though I don't know exactly how that works yet, so I'm taking simple steps.

I'm used to compiling under the MSVC++ 2013 compiler, so that's what I'm using, and I've come across this one last issue, I don't know how to deal with. What I'm going for first, if it doesn't compile right under its intended compiler, I'm obviously doing it wrong, and I shouldn't have to modify the code, yet.

Valve has this memoverride.cpp which has a char *__cdecl _strdup( const char *string ), which if I comment it out, the code compiles just fine, so this is the last issue I'm dealing with.

From this function "override" I'm getting the following two errors:

C2084: function 'char MemAlloc_StrDup(const char) already has a body

C2732: linkage specification contradicts earlier specification for 'MemAlloc_StrDup'

Does anybody know of any necessary compiler option, some default library that should be excluded, or a preprocessor define I should use to get around this? I tried compiling the code in Visual Studio, and disabled the suppressed startup banner so I could see all the options it was passing, but I tried them all, but it didn't seem to make any difference.

So anybody have some idea?

Any information would be greatly appreciated, thank you!

Weather Vane
  • 33,872
  • 7
  • 36
  • 56
Michael Barth
  • 45
  • 1
  • 5
  • 1
    TL, DR. *"memoverride.cpp"* Is this C or C++? – Weather Vane Mar 29 '16 at 20:16
  • It's C++. However, if you're going to suggest I edit the code with extern "C" or something, that's not the answer I'm looking for. And come on, it's not that long. – Michael Barth Mar 29 '16 at 20:19
  • 1
    Yes it is, most is just waffle. *"I'm used to compiling under the MSVC++ 2013 compiler, so that's what I'm using"* – Weather Vane Mar 29 '16 at 20:24
  • I'm not going to continue arguing over the matter, as I simply asked a question, but the compiler I'm using is most certainly relevant. Yes, the beginning part was a bit more background-esque. But it's not long at all. People here read many more lines of code with more characters than I wrote in my question. – Michael Barth Mar 29 '16 at 20:31

1 Answers1

0

The problem you have with a duplicate definition of MemAlloc_StrDup / strdup is probably caused by the fact that you can't have two definitions of strdup. There is no MSVC++ compiler option that solves precisely this.

It may "work" on other compilers because the One Definition Rule doesn't require the compiler to quit with an fatal error message, or even give a warning. But MSVC++ is completely in its right to just reject this.

MSVC++ allows you to not link its standard library. This is unlikely to solve your problem, as it's an all-or-nothing option.

MSalters
  • 173,980
  • 10
  • 155
  • 350