范围分辨率错误

时间:2016-04-24 06:01:27

标签: c++ visual-studio-2012 windows-7

我正在开发Windows中的共享内存。

我的代码中也是memorybarrier。在使用命令提示符编译visual studio 2012中的代码时,我收到错误。

#include "shmem_kk.h"

#ifdef _WIN32
#include <Windows.h>
#include <stdlib.h>

#else
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/msg.h>
#endif
#include <errno.h>
#include <pthread.h>
#include <unistd.h>


using namespace kk_win;

namespace IPC
{

    void
        Shm::get_lock(packet *map) {
            map[COUNT + 1].value = 1;               // flag[0] = 1
#ifdef _WIN32
            MemoryBarrier();            // compiler barriers
#else
            __sync_synchronize();
#endif
            map[COUNT + 3].value = 1;               // turn = 1
#ifdef _WIN32
            MemoryBarrier();            // compiler barriers
#else
            __sync_synchronize();
#endif
            while ((map[COUNT + 2].value == 1) && (map[COUNT + 3].value == 1)) {}
        }

    void
        Shm::release_lock(packet *map) {
            map[COUNT + 1].value = 0;
#ifdef _WIN32
            MemoryBarrier();            // compiler barriers
#else
            __sync_synchronize();
#endif
        }

在visual studio上我收到错误

shmem_kk.cc(30) : error C2668: '__faststorefence' : ambiguous call to overloaded function
        C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\intrin.h(302): could be 'void __faststorefence(voi
        C:\Program Files (x86)\Windows Kits\8.0\include\um\winnt.h(2824): or       'void kk_win::__faststorefence(void)
        while trying to match the argument list '(void)'
shmem_kk.cc(36) : error C2668: '__faststorefence' : ambiguous call to overloaded function
        C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\intrin.h(302): could be 'void __faststorefence(voi
        C:\Program Files (x86)\Windows Kits\8.0\include\um\winnt.h(2824): or       'void kk_win::__faststorefence(void)
        while trying to match the argument list '(void)'
shmem_kk.cc(47) : error C2668: '__faststorefence' : ambiguous call to overloaded function
        C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\intrin.h(302): could be 'void __faststorefence(voi
        C:\Program Files (x86)\Windows Kits\8.0\include\um\winnt.h(2824): or       'void kk_win::__faststorefence(void)
        while trying to match the argument list '(void)'

我该如何解决这个问题?

0 个答案:

没有答案