0

I've migrated a Visual C++ project to Visual Studio 2013. When I try to build the project, the compiler returns the following error :

Error 2 error C2169: '_InterlockedIncrement' : intrinsic function, cannot be defined

The error is in combase.h ( header from DirectShow ) and the code is :

static inline LONG WINAPI InterlockedIncrement(volatile LONG * plong) { return InterlockedIncrement( const_cast<LONG*>( plong ) ); }

InterlockedIncrement is defined in winnt.h as :

#define InterlockedIncrement _InterlockedIncrement

Do you know any solution for this error ?

Madalin
  • 129
  • 15
  • http://stackoverflow.com/a/18548135/17034 – Hans Passant Jan 11 '16 at 13:21
  • @HansPassant I have DirectShow libraries into ` ..\sdk\ ` folder. I have another project that compiled succesfully with the actual libraries so I think that there are some settings of the project that I've missed. Also, I've tried with `Enable Intrinsic Functions` ( both yes and no ) and I still have the same errors. – Madalin Jan 11 '16 at 13:34
  • For GraphStudioNext we have the [baseclasses](https://github.com/cplussharp/graph-studio-next/tree/master/baseclasses) as part of the solution. There is also a VS2013 project for it. – CPlusSharp Jan 11 '16 at 18:21

1 Answers1

1

Your #define replaces all the occurrences of InterlockedIncrement with _InterlockedIncrement, so static inline LONG WINAPI InterlockedIncrement(volatile LONG * plong) becomes static inline LONG WINAPI _InterlockedIncrement(volatile LONG * plong).

Which means you actually are trying to define the _InterlockedIncrement function, which is prohibited as it's an intrinsic.

I think you need to remove

#define InterlockedIncrement _InterlockedIncrement

and make InterlockedIncrement call _InterlockedIncrement with appropriate argument conversion if needed.

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • 1
    The `#define` it's actually in winnt.h which is a header from Windows SDK, so I didn't defined `InterlockedIncrement` – Madalin Jan 11 '16 at 11:56
  • or first `#undef InterlockedIncrement` and then use `static inline LONG WINAPI InterlockedIncrement(volatile LONG * plong) { return _InterlockedIncrement( const_cast( plong ) ); }` – wimh Jan 16 '16 at 14:09