Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi, I'm SUN MI -- I used visual studio 2010

my error suddenly happen in this part (-- _- -) Plz help me


when you have idea, email me in *REMOVED MAIL*
if (!InitializeCriticalSection && SpinCount(&m_sec, 0))
{
  hRes = HRESULT_FROM_WIN32(GetLastError());
}

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error 2 error C3861: 'SpinCount': cannot find. d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcore.h 115 1 Commu

3 IntelliSense: 식별자 "SpinCount"이(가) no definition. d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcore.h 115 37


warning 1 warning C4551: cannot call. d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcore.h 115 1 Commu
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

This file is atlcore.h
#ifndef __ATLCORE_H__
#define __ATLCORE_H__

#pragma once
#ifdef _ATL_ALL_WARNINGS
#pragma warning( push )
#endif
#pragma warning(disable: 4786) // identifier was truncated in the debug information
#pragma warning(disable: 4127) // constant expression
#include <atldef.h>
#include <windows.h>
#include <ole2.h>
#include <limits.h>
#include <tchar.h>
#include <mbstring.h>
#include <atlchecked.h>
#include <atlsimpcoll.h>
//#include <Wingdi.h>
#include <WinNT.h>
#if _WIN32_WINNT < 0x0403
//#error This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended.
#endif
#pragma pack(push,_ATL_PACKING)
namespace ATL
{
/////////////////////////////////////////////////////////////////////////////
// Verify that a null-terminated string points to valid memory
inline BOOL AtlIsValidString(
	_In_z_count_(nMaxLength) LPCWSTR psz,
	_In_ size_t nMaxLength = INT_MAX)
{
	(nMaxLength);
	return (psz != NULL);
}
// Verify that a null-terminated string points to valid memory
inline BOOL AtlIsValidString(
	_In_z_count_(nMaxLength) LPCSTR psz,
	_In_ size_t nMaxLength = UINT_MAX)
{
	(nMaxLength);
	return (psz != NULL);
}
// Verify that a pointer points to valid memory
inline BOOL AtlIsValidAddress(
	_In_opt_bytecount_(nBytes) const void* p,
	_In_ size_t nBytes,
	_In_ BOOL bReadWrite = TRUE)
{
	(bReadWrite);
	(nBytes);
	return (p != NULL);
}
template<typename T>
inline void AtlAssertValidObject(
	_In_opt_ _Prepost_opt_bytecount_x_(sizeof(T)) const T *pOb)
{
	ATLASSERT(pOb);
	ATLASSERT(AtlIsValidAddress(pOb, sizeof(T)));
	if(pOb)
		pOb->AssertValid();
}
#ifdef _DEBUG
#define ATLASSERT_VALID(x) ATL::AtlAssertValidObject(x)
#else
#define ATLASSERT_VALID(x) __noop;
#endif
// COM Sync Classes
class CComCriticalSection
{
public:
	CComCriticalSection() throw()
	{
		memset(&m_sec, 0, sizeof(CRITICAL_SECTION));
	}
	~CComCriticalSection()
	{
	}
	HRESULT Lock() throw()
	{
		EnterCriticalSection(&m_sec);
		return S_OK;
	}
	HRESULT Unlock() throw()
	{
		LeaveCriticalSection(&m_sec);
		return S_OK;
	}
	HRESULT Init() throw()
	{
		HRESULT hRes = S_OK;
		void InitializeCriticalSectionSpinCount(LPCRITICAL_SECTION CRITICAL_SECTION,DWORD SpinCount);
		if (!InitializeCriticalSection && SpinCount(&m_sec, 0))
		{
			hRes = HRESULT_FROM_WIN32(GetLastError());
		}
		return hRes;
	}
	HRESULT Term() throw()
	{
		DeleteCriticalSection(&m_sec);
		return S_OK;
	}
	CRITICAL_SECTION m_sec;
};
class CComAutoCriticalSection : 
	public CComCriticalSection
{
public:
	CComAutoCriticalSection()
	{
		HRESULT hr = CComCriticalSection::Init();
		if (FAILED(hr))
			AtlThrow(hr);
	}
	~CComAutoCriticalSection() throw()
	{
		CComCriticalSection::Term();
	}
private :
	HRESULT Init(); // Not implemented. CComAutoCriticalSection::Init should never be called
	HRESULT Term(); // Not implemented. CComAutoCriticalSection::Term should never be called
};
class CComSafeDeleteCriticalSection : 
	public CComCriticalSection
{
public:
	CComSafeDeleteCriticalSection(): m_bInitialized(false)
	{
	}
	~CComSafeDeleteCriticalSection() throw()
	{
		if (!m_bInitialized)
		{
			return;
		}
		m_bInitialized = false;
		CComCriticalSection::Term();
	}
	HRESULT Init() throw()
	{
		ATLASSERT( !m_bInitialized );
		HRESULT hr = CComCriticalSection::Init();
		if (SUCCEEDED(hr))
		{
			m_bInitialized = true;
		}
		return hr;
	}
	HRESULT Term() throw()
	{
		if (!m_bInitialized)
		{
			return S_OK;
		}
		m_bInitialized = false;
		return CComCriticalSection::Term();
	}
	HRESULT Lock()
	{
Posted
Updated 27-Mar-11 18:53pm
v2

1 solution

Isn't that obvious? If it says "SpinCount... no definition" it means you did not define it. Where is the code you tried to define it?

The name sounds like a suspect to me: are you sure you do not spin wait? You should never use such thing. Instead, you have to use threads and Event wait handle (see CreateEvent, CreateEventEx, WaitForSingleObject).

—SA
 
Share this answer
 
Comments
Sun-Mi Kang 27-Mar-11 23:19pm    
I send file to your homepage,, Anyway, thanks ~
Sergey Alexandrovich Kryukov 28-Mar-11 0:28am    
I took a look. Project did not compile, reported 10 compilation errors, but I fixed in a minute. You have a strange habit to use undeclared variables. They all were the loop variables in "for" loops. When I declared 2 or 3 of them "int", project compiled. The fact you could not fix it soon enough shows that you have a problem understanding most basic compiler messages. Probably, you need to learn most elementary basics of C++ and programming. I have no idea how anyone can help you before you learn such staff.
--SA
Sergey Alexandrovich Kryukov 28-Mar-11 0:28am    
Are you going to formally accept this Answer? I gave you all you need.
--SA
Sun-Mi Kang 28-Mar-11 0:34am    
Thanks
Sergey Alexandrovich Kryukov 28-Mar-11 0:45am    
Does it mean "no"?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900