This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Simple Code Question - undefined identifier

Hi,

I've encountered an issue with Code composer studio, see the following code snippet:

bool flag = false;

if(flag==false)
{ 
int var=0;
flag=true;
}

if(flag==true)
{
var=10;
}


In this case var is marked as undefined and CCS generates an error, which is also right! As long as a variable is defined inside an if statement it's not know to the outside. For sure you can rewrite the code in this case. But in my actual code I've to built an object from a class with a non default constructor and it can't be solved otherwise than with an if statement (at least I don't have an idea how)

My actual code:

SelectedSocket2=VCRT_selectset(&MasterSocket,1,-1); 
	
 if((SelectedSocket != VCRT_SOCKET_ERROR) && (SelectedSocket != 0))
 {
ClientSocket=accept(MasterSocket, NULL, NULL);
CStreamer    Streamer(ClientSocket);                  
CRtspSession RtspSession(ClientSocket,&Streamer);     	   
flag=true;
}
//Streamer, RtspSession are outside unknown and CCS generates an error

Any ideas how I can solve the issue or trick the compiler?


Thank you in advance!