Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)

Posted on 2006-03-20
2
Medium Priority
?
4,474 Views
Last Modified: 2012-05-05
Hi,
Here's the other warning I receive when I compile the source code.
//------------------------
warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
//------------------------

The line incriminated is between two lines like this: //-------------------------------------------------------------------------

Here's all the code
//*************************** BEGINNING OF THE CODE
#ifndef cUnknownPtr_DEFINED
#define cUnknownPtr_DEFINED

template <typename T>
class cUnknownPtr
{
  T* ptr;
public:
  cUnknownPtr() : ptr(0)
  {
  }

  cUnknownPtr(T* p) : ptr(p)
  {
  }

  cUnknownPtr(const cUnknownPtr<T>& other) : ptr(other.ptr)
  {
    if(ptr)
    {
      ptr->AddRef();
    }
  }

  ~cUnknownPtr()
  {
    setNull();
  }

  cUnknownPtr<T>& operator = (const cUnknownPtr<T>& other) //treat as pointer
  {
    if(other.ptr != ptr)
    {
      if(ptr)ptr->Release();
      ptr = other.ptr;
      if(ptr)ptr->AddRef();
    }
    return *this;
  }

  T* operator -> () //treat as pointer
  {
    return ptr;
  }

  operator T* () //silent cast operator
  {
    return ptr;
  }

  T** operator & () //address of operator
  {
    return &ptr;
  }

  bool isValid()
  {
    return ptr != 0;
  }

  bool isNull()
  {
    return ptr == 0;
  }

  void setNull()
  {
    if(ptr)
    {
      ptr->Release();
      ptr = 0;
    }
  }

  bool QI(REFIID riid,void** ppObj)
  {
    if(isNull())return false;
    return SUCCEEDED(ptr->QueryInterface(riid,ppObj));
  }

//----------------------------------------------------------------------
void demandQI(REFIID riid,void** ppObj) throw(HRESULT)
//----------------------------------------------------------------------
  {
    if(isNull())throw E_FAIL;
    HRESULT hr = ptr->QueryInterface(riid,ppObj);
    if(FAILED(hr))
    {
      throw hr;
    }
  }
};

inline void checkResult(HRESULT r)
{
  if (FAILED(r))
    throw r;
}

#endif//cUnknownPtr_DEFINED
//*************************** END OF THE CODE

THANKS YOU FOR ANY ADVICE...
0
Comment
Question by:racineconde
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 1600 total points
ID: 16236873
C++ compiler allows this feature for future use, but doesn't implement it. throw(HRESULT) part is not implemented currently, as described in the C4290 MSDN topic. To turn off this warning add:

#pragma warning( disable : 4290 )

0
 

Author Comment

by:racineconde
ID: 16237123
I'm very impressed Alex... very impressed...
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question