Why won't clang compile this source code that works in VS2012?

Sod*_*hty -46 c++ compiler-errors clang

I don't know if I'm doing something wrong here, but I can't for the life of me get clang to compile existing code that compiles fine in VS2012.

Includes like strsafe.h and xstring cause weird compilation errors, the strangest of which is a "missing close bracket" in the middle of a standard include file. Needless to say, there is no missing bracket. Further, move.h causes clang to throw up with

fatal error: expected function body after function declarator.

Guard clauses like

#ifndef _FUNCTIONAL_
#error Must include <functional>
#endif
Run Code Online (Sandbox Code Playgroud)

throw errors even though functional has been included.

What am I doing wrong?

Mic*_*urr 15

Headers included with one compiler are typically tailored to that compiler implementation and will not necessarily work correctly with a different compiler.

So generally speaking you won't be able use the headers that come with Visual Studio with another compiler.


Che*_*Alf 6

Re

“Includes like strsafe.h and xstring cause weird compilation errors,”

those are Visual C++ headers.

clang probably doesn't have anything like them.

A main problem is that you're using low level C string functions, which Microsoft (rightly!) regards as problematic and (wrongly) convince you are deprecated.

Use std::string instead.