warning C4541: 'dynamic_cast' used on polymorphic type 'cSegment' with /GR-; unpredictable behavior may result

This is a warning I have when i compile my windows application.
//------
warning C4541: 'dynamic_cast' used on polymorphic type 'cSegment' with /GR-; unpredictable behavior may result
//------

I've put the incriminated line between two lines like this //------------------------------------------------------


Here's the whole code:

//****************************** BEGINNING OF THE CODE
#include "stdafx.h"
#include "cTimeCode.h"
#include "cEdlData.h"
#include "cAafEdl.h"
#include "cWipe.h"
#include "cCut.h"

cWipe::cWipe(aafInt32 smpte,int duration,aafBoolean_t reverse)
 : Smpte(smpte), Duration(duration), Reverse(reverse)
{
}

void cWipe::print()
{
  edit();
  wcout << L" W:" << setw(3) << Smpte << L" " << setw(3) << Duration << L" ";
  frames();
}

cUnknownPtr<IAAFComponent> cWipe::createTransition(cUnknownPtr<IAAFDictionary> pDictionary,cUnknownPtr<IAAFDataDef> pDataDef)
{
  cUnknownPtr<IAAFComponent> pComponent;
  if(Duration>0 && length() > 0)//ignore zero length disolves
  {
    //transition
    aafBoolean_t IsSound;
    checkResult(pDataDef->IsSoundKind(&IsSound));

    cUnknownPtr<IAAFOperationDef> pOperationDef;
    cUnknownPtr<IAAFParameterDef> pParameterDefSMPTE;
    cUnknownPtr<IAAFParameterDef> pParameterDefReverse;
    if(!IsSound)
    {
      GetWipe(pDictionary,pDataDef,&pOperationDef);
      GetWipeParamSMPTE(pDictionary,pDataDef,&pParameterDefSMPTE);
      GetWipeParamReverse(pDictionary,pDataDef,&pParameterDefReverse);
    }
    else
    {
      //wipes do not make sense for sound data - so wipes make audio *disolves*
      GetDisolve(pDictionary,pDataDef,kAAFEffectMonoAudioDissolve,&pOperationDef);
    }

    cUnknownPtr<IAAFOperationGroup> pOperationGroup;
    checkResult(pDictionary->CreateInstance(AUID_AAFOperationGroup,IID_IAAFOperationGroup,(IUnknown **)&pOperationGroup));
    checkResult(pOperationGroup->Initialize(pDataDef,Duration,pOperationDef));

    cUnknownPtr<IAAFTransition> pTransition;
    checkResult(pDictionary->CreateInstance(AUID_AAFTransition,IID_IAAFTransition,(IUnknown **)&pTransition));

    if(pParameterDefSMPTE.isValid())
    {
      cUnknownPtr<IAAFConstantValue> pConstantValue;
      checkResult(pDictionary->CreateInstance(AUID_AAFConstantValue,IID_IAAFConstantValue,(IUnknown **)&pConstantValue));
      checkResult(pConstantValue->Initialize(pParameterDefSMPTE,sizeof(Smpte),(unsigned char*)&Smpte));

      cUnknownPtr<IAAFParameter> pParameter;
      pConstantValue.demandQI(IID_IAAFParameter,(void**)&pParameter);
      checkResult(pOperationGroup->AddParameter(pParameter));
    }

    if(pParameterDefReverse.isValid())
    {
      cUnknownPtr<IAAFConstantValue> pConstantValue;
      checkResult(pDictionary->CreateInstance(AUID_AAFConstantValue,IID_IAAFConstantValue,(IUnknown **)&pConstantValue));
      checkResult(pConstantValue->Initialize(pParameterDefReverse,sizeof(Reverse),(unsigned char*)&Reverse));

      cUnknownPtr<IAAFParameter> pParameter;
      pConstantValue.demandQI(IID_IAAFParameter,(void**)&pParameter);
      checkResult(pOperationGroup->AddParameter(pParameter));
    }


    checkResult(pTransition->Initialize(pDataDef,Duration,0,pOperationGroup));
    pTransition.demandQI(IID_IAAFComponent, (void **)&pComponent);

    setEditNumber(pDictionary,pComponent,getEditNumber());
  }
  return pComponent;
}

bool cWipe::removeZeroLengthCut(cSegment::Ptr prevprev,cSegment::Ptr prev)
{
  // remove zero length cut (if any) preceding transition
  // if zero length cut (prev) matches segment preceding it (prevprev)

  bool removePrev = false;

  if (prev->length() != 0) return removePrev; // must be zero length

//---------------------------------------------------------------------------------------------------------------------
  if (!dynamic_cast<cCut::Ptr>(prev)) return removePrev; // must be cut
//---------------------------------------------------------------------------------------------------------------------
  // check tape names match
  wstring prevCassette = prev->cassette();
  wstring prevprevCassette = prevprev->cassette();
  if(MERGE_B_ROLLS && !prevCassette.empty())
  {
    wstring::iterator it = prevCassette.end();
    --it;
    if(*it == L'B') prevCassette.erase(it,prevCassette.end()); // remove 'B' if B roll
  }
  if(MERGE_B_ROLLS && !prevprevCassette.empty())
  {
    wstring::iterator it = prevprevCassette.end();
    --it;
    if(*it == L'B') prevprevCassette.erase(it,prevprevCassette.end()); // remove 'B' if B roll
  }
  if (prevCassette != prevprevCassette) return removePrev;

  // check speed ratios match
  aafRational_t prevSpeed = prev->speedRatio();
  aafRational_t prevprevSpeed = prevprev->speedRatio();
  if ((prevSpeed.numerator * prevprevSpeed.denominator) != (prevprevSpeed.numerator * prevSpeed.denominator)) return removePrev;

  // check prev source tc falls within prevprev segment
  cTimeCode prevSrcTc = prev->in();
  cTimeCode prevprevSrcIn = prevprev->in();
  cTimeCode prevprevSrcOut = prevprev->out();
  if ((prevSrcTc < prevprevSrcIn) || (prevSrcTc > prevprevSrcOut)) return removePrev;

  removePrev = true; // indicates that prev segment should be removed
  return removePrev;
}

void cWipe::adjust(cSegment::Ptr prev,bool sound)
{
  prev->adjustDestOut(Duration);

  if(sound)
  {
    prev->setOutFade(Duration);
  }
}

cSegment::Ptr cWipe::clone()
{
  cWipe::Ptr seg = new cWipe(Smpte,Duration,Reverse);
  seg->set(getEditNumber(), cassette(), in(), destIn(), destOut(), speedRatio());
  return seg;
}

int cWipe::getTransitionDuration()
{
  return Duration;
}

//****************************** END OF THE CODE

Is someone has an idea???


racinecondeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlexFMCommented:
Using dynamic_cast with polymorphic type requires run-time type information (RTTI), and it is disabled in your project. To enable it, use compiler switch /GR.
To enable this feature in project settings, open Project - Properties - Configuration Properties - C/C++ - Language. Set "Enable Run-Time Type Info" to Yes.
This warnibg should not be ignored.
AxterCommented:
Hi racineconde,
> warning C4541: 'dynamic_cast' used on polymorphic type 'cSegment' with
> /GR-; unpredictable behavior may result

You need to change your project compile settings.
You can do this by going to your project property settings, and clicking on C/C++, and than Language.
Than change the "Enable Run-Time Type Info" setings to Yes(/GR)


David Maisonave (Axter)
Cheers!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AxterCommented:
Looks like AlexFM beat me to the punch line while I was typing.... :-)
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

racinecondeAuthor Commented:
Sorry Axter... But thanks for trying...
AlexFMCommented:
Thanks Axter. This was simultaneous post, splitting will be also OK. racineconde, for your decision.
racinecondeAuthor Commented:
I mixed up everything:
Accepted answer --> AlexFM
Assisted answer --> Axter

Thanks guys
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.