locked
second linkage of _interlockedbittestandreset halts compiler

    Question

  • While trying to determine how to solve a compile error C2733 around intrin.h when porting my code from Visual Studio 2005 to Visual Studio 2010 beta2 I've found out that I get the same error even when I create a new Win32 Project from the wizard.

    I only have to #include <vector> at the end of auto-generated stdafx.h

    eg
    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    //

    #pragma once

    #include "targetver.h"

    #define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
    // Windows Header Files:
    #include <windows.h>

    // C RunTime Header Files
    #include <stdlib.h>
    #include <malloc.h>
    #include <memory.h>
    #include <tchar.h>


    // TODO: reference additional headers your program requires here
    #include <vector>

    If I comment the line: #include <vector> everything works fine otherwise I get:

    1>------ Rebuild All started: Project: Test, Configuration: Debug Win32 ------
    1>  stdafx.cpp
    1>c:\program files\microsoft visual studio 10.0\vc\include\intrin.h(1060): error C2733: second C linkage of overloaded function '_interlockedbittestandset' not allowed
    1>          c:\program files\microsoft visual studio 10.0\vc\include\intrin.h(1060) : see declaration of '_interlockedbittestandset'
    1>c:\program files\microsoft visual studio 10.0\vc\include\intrin.h(1061): error C2733: second C linkage of overloaded function '_interlockedbittestandreset' not allowed
    1>          c:\program files\microsoft visual studio 10.0\vc\include\intrin.h(1061) : see declaration of '_interlockedbittestandreset'
    ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

    And that's from an dummy project created from the wizard.

    Any help?

    Iosif Hamlatzis
    Monday, January 18, 2010 7:56 AM

All replies

  • Hi: this is a problem with the header files - there are two incompatible declarations of '_interlockedbittestandset' - this issue has been fixed since the Beta release.
    Jonathan Caves - Visual C++ Compiler Team
    Monday, January 18, 2010 5:51 PM
  • Hi: this is a problem with the header files - there are two incompatible declarations of '_interlockedbittestandset' - this issue has been fixed since the Beta release.
    Jonathan Caves - Visual C++ Compiler Team

    I'm sorry to say, but when I posted my question above, I had just downloaded and installed the Visual Studio 2010 beta 2 version, which I believe is/was the latest version.

    As I've mentioned not only my converted 2005 -> 2010 project had the above compile error, but also a dummy project created from the wizard produced the same compile error.
    Wednesday, January 20, 2010 8:14 AM
  • As I work for Visual C++ I have access to much newer builds. I just tested it again against yesterday's build and I didn't see the error message - there was an issue with the header files we get from the Windows SDK team - but this issue has been fixed.


    Jonathan Caves - Visual C++ Compiler Team
    Wednesday, January 20, 2010 4:18 PM
  • As I work for Visual C++ I have access to much newer builds. I just tested it again against yesterday's build and I didn't see the error message - there was an issue with the header files we get from the Windows SDK team - but this issue has been fixed.


    Jonathan Caves - Visual C++ Compiler Team

    I haven't installed any SDK as I don't need them for now.

    My intrin.h file in c:\program files\microsoft visual studio 10.0\vc\include\ at line 1060 reads: 
    __MACHINEI(unsigned char _interlockedbittestandset(long volatile *a, long b))

    and the macros are:
    #define __MACHINE(X)          X;
    #define __MACHINEI            __MACHINE

    any idea how I can fix this?
    Thursday, January 21, 2010 1:50 PM
  • For now I would just comment out the second declaration.
    Jonathan Caves - Visual C++ Compiler Team
    Thursday, January 21, 2010 10:00 PM
  • Thank you very much, it worked!
    Friday, January 22, 2010 8:29 AM
  • I have the same problem with Visual Studio 2010 Ultimate (final release) and Windows Server 2003 SP1. I am compiling code that needs to be built against an older SDK than what comes with VS 2010, hence the 2003 SDK.

    Now, I was wondering what's the best way to resolve this issue without touching the VS 2010 files? I need to compile many projects from different devlopers/times and I don't feel comfortable fiddling with system files.

    I appreciate your advice.

    Monday, August 16, 2010 7:15 PM
  • Look for the following files:

     

    Microsoft.Cpp.Win32.user.props

    Microsoft.Cpp.x64.user.props

     

    They're not editable ANYWHERE in the VS2010 interface and will contain paths to SDKs that you do not want included in your build.  You need to manually edit them.  They're just XML files.  You'll need to search your hard drive to find them or look under your user folder under Application Data.  This is absolutely nuts.  Nowhere in the GUI for VS2010 can you edit these and look at the settings they contain, but your projects will all inherit from them.  The bad SDK paths are put   in there by the import feature of VS2010.  Yes, I'm using the currently released "Professional" version.  Hence for me the problem only appeared on one machine, the machine I did the import on.

     

    I lost an entire day to this.  Don't be it's next victim.

     

    "We're all in this together" - marmotking

    Thursday, November 11, 2010 2:46 AM
  • Hi, these user files can be changes through UI. You can take a look of my blog http://blogs.msdn.com/b/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx

    3)       VC++ Directories change

    VC++ Directories are no longer supported in VS2010 through Tools->Options page. Instead, VS2010 introduces the user settings file (Microsoft.cpp.<Platform>.users.props) to control global settings including Global search path. These files are located at $(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0 directory. Upon migration to VS2010, the custom settings of VC++ Directories from VS2005 or VS2008 are migrated to these user files. These global settings files are imported into all the converted and newly created projects.

     Here are the steps to change the settings file through UI:

    ·         Open up property manager by clicking on View.Property Manager.

    ·         Expand the project node and then the Configuration|Platform nodes, you will see "Microsoft.cpp.<Platform>.users" file for each Configuration|Platform. These are the files for the global settings, similar to the old tools/Options/VC++ Directories.

    ·         Multi-Select "Microsoft.cpp.<Platform>.users", right click and bring up the property page window

    ·         In the property page window, click on "VC++ Directories" (for example) in the left pane, add new paths for the directories such as "Include Directories". separated by semicolons

    ·         Make sure to save the settings before shutting down Visual Studio.

    ·         Re-launch Visual Studio and the new settings will be in effect.

    -Note: If you would like to only change the settings for one project, you can right click on the project and bring up the property page. Change the settings for “VC++ Directories”, these settings will be persisted to the project file.

     


    Li Shao
    Friday, November 12, 2010 1:13 AM