Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

InterlockedIncrement not found when using /clr and Windows 8.1 SDK in MFC dll VS 2012 project

$
0
0

I have a MFC DLL project in Visual Studio 2012 C++ that I am in need of using the /clr switch as the project uses a hybrid mix of native and managed C++ and calls into C# reference class libraries.  When I compile the project against the Window 8.0 SDK, all is good.  But when I try the Windows 8.1 SDK the project won't compile because it kicks out a bunch of missing entries related to InterlockedIncrement and InterlockedDecrement referenced by ATL classes.

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlsimpstr.h(93): error C3861: 'InterlockedIncrement': identifier not found

To replicate this issue...
1) Assumed that Visual Studio 2012 is installed, W8.0 SDK is installed at C:\Program Files (x86)\Windows Kits\8.0 and W8.1 SDK installed at C:\Program Files (x86)\Windows Kits\8.1
2) Create a Visual Studio 2012 MFC DLL project (defaults to MFCLibrary1)
3) Accept all defaults
4) From the Project properties...in Configuration Properties node...Common Language Runtime Support, select "Common Language Runtime Support (/clr)"
5) Use 8.0 SDK Include...From the Project properties...in C++ Directories clear out contents and paste in "C:\Program Files (x86)\Windows Kits\8.0\Include\um;C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include;"
6) Compile the project, all is well.
7) Use 8.0 SDK Include...From the Project properties...in C++ Directories clear out contents and paste in "C:\Program Files (x86)\Windows Kits\8.1\Include\um;C:\Program Files (x86)\Windows Kits\8.1\Include\shared;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include;"
8) Clean and Compile the project....error C3861: 'InterlockedIncrement': identifier not found

NOTE: I am aware that you should update the bin, lib, etc for a complete 8.0 vs 8.1 SDK project, but saved time omitting those steps.

Setting WINVER/_WIN32_WINNT to _WIN32_WINNT_WIN7 did not make a difference.

I might be able to get around this by defining InterlockedIncrement myself and then doing a GetProcAddress to dynamically call it but that isn't ideal and not sure if I am going to run into any additional issues.


Viewing all articles
Browse latest Browse all 15302

Trending Articles