[ECOS] What's the meaning of those C++ code? Thanks.

Jonathan Larmour jifl@eCosCentric.com
Fri Apr 25 18:17:00 GMT 2003


QiangHuang wrote:
> 
> so when declares:
> 
> cyg_mutex_t mutex1;
> cyg_mutex_init(&mutex1);
> 
> what's the meaning of  "(1). Cyg_Mutex *m = new((void *)mutex) Cyg_Mutex;
> (2). m=m;"  here? Thanks a lot.

It's a construct called placement new. e.g. 
http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.10

m=m avoids an "unused variable" warning, that's all.

Jifl
-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list