q & a from c, c++, linux, vxworks

Upload: mukesh

Post on 11-Feb-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    1/38

    XJ]W :

    Z & J `}ao C C++ Fdiu~ P^|a}ks

    :$\njw ds Wu~\na cadieg |a}g Wu~\nei Wu~ law dws ijoe Wu~

    |njw ds wne jc}aito a` Wu~

    J$Wu~ ds wne a``dcdjf ojscaw a` wne Fdiu~ axe}jwdil stsweo) Wu~& c}ejweg mt Fj}}t E|dil di :440& ds j cnummtxeiludi wnjw faaks caiweiw jig sjwds`deg) Wne caicexw a` wne Fdiu~ ojscaw medil j xeiludi cjoe `}ao FdiusWa}pjfgs& wne c}ejwa} a` wne Fdiu~ ke}ief)

    Dw ds saoewdoes cfjdoeg wnjw wne ijoe |js ge}dpeg `}ao Wa}pjfgs Uid^& j ijoe sullesweg mt BjoesNulnes& }jwne} wnji wne e~xfjijwdai wnjw xeiludis faak pjlueft js d` wnet j}e |ej}dil j wu~ega)

    =$ |}dwe j C cage wnjw e~ecuwes mawn dws d` jig efse xj}w1

    Wnds ds aie zudck |jt&ojdi.${d`.:${x}diw`.-Disdge D@-$;lawa e;efse{e2;x}diw`.-disdge EFSE-$;

    }ewu}i :;

    3$ cji jit aie x}diw -neffa- |a}g |dwnauw usdil jit usdil jit `uicwdai fdke))x}diw`&`x}diw`)))ewc

    J$ #e}}a} neffa *

    diw ojdi.padg${}ewu}i 8;

    7$ |nt di C &swa}jle facjwdai a` j}}jt swj}ws `}o 8wn xasdwdai |ne}eejs di XJSCJF dw swj}ws `}o :wn facjwdai1j[8_ di C |ne}ejs di XJSCJF dws j[:_)

    J$ Xjscjf .jig saoe awne} fjilujles$ suxxa}ws j}}jts |dwn digdces ape} jit j}mdw}j}t }jile .d)e) iaw busw :/mjseg$) Na|epe} wnds ds busw stiwjcwdc sulj} / wne uige}tfdil j}}jt ds busw j 8/mjseg j}}jt jw wne ojcndiecage fepef) Ndlne} fepef fjiljules a``e} wnds kdig a` `ejwu}e js ji jdg wa wne x}al}jooe}& |ne}ejs C ds j}efjwdpeft fa| fepef fjilujle& |dwn odidojf `ejwu}es jig `}dffs)

    Tau cji jcwujfft sdoufjwe :/mjseg .a} jit I/mjseg$ j}}jts di C / dw,s iaw waa nj}g) D,pe gaie dw otsef` |nei Dieegeg j}}jts wnjw njg ijwu}jf digdces `}ao /: wa I& e)l)

    diw Qj}}jt[I + =_; !! uige}ftdil swa}jle `a} j}}jtdiw " caisw j}}jt ? Qj}}jt[:_; !! j}}jt njs pjfdg digdces `}ao /:))I

    :

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    2/38

    5$ Ds dw xassdmfe wa |}dwe j C x}al}jo |dwnauw ojdi.$ `uicwdai1

    J$ wne}es j |jt)) di |ndcn wne ojdi.$ gaesiw jxxej} e~xfdcdwft)) wnjw ds )) u |dff iaw `dig -ojdi.$- |}dwweijit|ne}e di wne x}al}jo)) muw dw |dff me pd}wujfft x}eseiw)

    ndiw2 use #ge`die jig caicjweijwdai x}ex}acessa} gd}ecwdpe))) d)e) # #

    #dicfuge 6swgda)n9#ge`die gecage.s&w&u&o&x&e&g$ o##s##u##w#ge`die meldi gecage.j&i&d&o&j&w&e$meldi.${x}diw`.-Swuoxeg11Vi-$;

    ia| gaiw swj}w sc}ejodil& wnjw wne ojdi.$ ds digd}ecwft x}eseiw) d wafg dw me`a}enjig wnjw dw |aufg me x}eseiwpd}wujfft muw |aiw jxxej} e~xfdcdwt di wne x}al}jo)

    Jit |jt ojdi |dff me x}eseiw j`we} x}ex}acessdil a` wnjw cage)D` u see wne x}ex}acesseg cage dw |dff me fdke mefa|

    ojdi.${x}diw`.-Swuoxeg11Vi-$;

    Sjoe jis `a} wne jmape zues2

    !" neffa)c "!# dicfuge 6swgda)n9

    padgneffa . padg ${x}diw` . -Neffa \a}fgVi- $;

    e~dw . 8 $;

    cc neffa)c /iaswj}w`dfes

    Dlia}e wne |j}idil jig e~ecuwe wne j)auw

    0$|jw ds wne use di swugtdil gjwj sw}ucwu}es1

    J$gjwj sw}ucwu}es ds ojdift useg `a} wne ojidxufjwdai ai gjwjwne ojdi `defgs a` gjwj sw}ucwu}es dicfuge w}ees&sej}cnes&sa}ws&fdikeg fdsws&njsndil oufwdfepef dige~dil)jff wne wne jmape `defgs nefx us wa swa}e wne gjwj di ji e``dcdeiw |jt|dwnauw jit |jswjle a` oeoa}t sxjce)sa}ws keex au} gjwj a}ljidseg di j ststweojwdc ojiie}

    J$xu}xase a` gjwj sw}ucwu}e\e busw gaiw la wa wne cfjsdcjf ge`didwdai a` j Gjwj Sw}ucwu}e& wa me sdoxfe j gjwjsw}ucwu}e ds j}}jildil gjwj disaoe |jt))|njw epe} |jt u j}jile gjwj wnjw ds j gjwjsw}ucwu}e)

    X}jcwdcjfft& |e |jiw wa ojdiwjdi di`a}ojwdai a` swugeiws di j cfjss jig wnese swugeiws j}e `d~eg) jig wnet j}eiuome}s : wa i& `a} wnds jxxfdcjwdai sudwjmfe Gjwjsw}ucwu}e ds -J}}jt-)

    Gdcwaij}t Jxxfdcjwdai& d` jw jff |e use j}}jt `a} ojdiwjdil jff |a}gs di`a}ojwdai& dws wjkes I wdoes wa `dig wneojwcn)

    =

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    3/38

    @a} Axwdodrdil wnds Sudwjmfe GS ds Mdij}t W}ee)jff |a}gs j}e jggeg wa wnds mdij}t w}ee))sa sej}cndil di MSW ds A.fal i$@a} oucn mewwe} safuwdai dige~dil |dwn mdij}t w}ee |dff me mewwe}))

    $ diw ojdi.${VVmagtlewcn.$;}ewu}i 8;ne}e }ewu}i 8; swjweoeiw }ewu}is pjfue 8 wa ojdi `uicwdai)

    \NJW dw oejis11111cji jitaie e~xfjdi dw)

    J$ Dw gaes iaw }ewu}i wne pjfue wa ojdi& muw ojdi }ewu}is wne pjfue wa wne AS .a} oa}e ca}}ecw wa wne cjffdilx}acess$

    ojdi,s }ewu}i pjfue ds useg wa gewe}odie d` wne x}al}jo njs e~dweg success`ufft a} |dwn ji e}}a}) Xe}caipeiwdai& 8 oejis ia e}}a}& pjfues a` : jig jmape digdcjwe ji e}}a} a} ji uieccss`uff }ui) \njw pjfue ds}ewu}ieg ai |njw kdig a` e}}a}!x}amfeo ds x}al}jo sxecd`dc)

    4$|njw ds j Gjilfdil xadiwe}1

    J$ D,o su}e \dkdxegdj cape}s dw di oa}e gewjdf& muw D,ff mdwe) J xadiwe} ds j oeoa}t jgg}ess /// dw -xadiws- wajiawne} xj}w a` oeoa}t) Jit xj}wdcufj} xj}w a` oeoa}t cji edwne} me pjfdg a} dipjfdg) D` j xadiwe} xadiws wa jidipjfdg xdece a` oeoa}t& dw ds gjilfdil)

    Gjilfdil xadiwe}@}ao \dkdxegdj& wne `}ee eictcfaxegdj

    Gjilfdil xadiwe}s jig |dfg xadiwe}s di caoxuwe} x}al}joodil j}e xadiwe}s wnjw ga iaw xadiw wa j pjfdg ambecwa` wne jxx}ax}djwe wtxe& a} wa j gdswdiludsneg iuff xadiwe} pjfue di fjilujles |ndcn suxxa}w wnds) Gjilfdilxadiwe}s j}dse |nei ji ambecw ds gefeweg a} gejffacjweg& |dwnauw oagd`tdil wne pjfue a` wne xadiwe}& sa wnjwwne xadiwe} swdff xadiws wa wne oeoa}t facjwdai a` wne gejffacjweg oeoa}t) Js wne stsweo ojt }ejffacjwe wnex}epdausft `}eeg oeoa}t wa jiawne} x}acess& d` wne a}dldijf x}al}jo wnei ge}e`e}eices wne .ia|$ gjilfdilxadiwe}& uix}egdcwjmfe menjpda} ojt }esufw& js wne oeoa}t ojt ia| caiwjdi caoxfeweft gd``e}eiw gjwj)

    Wnds ds esxecdjfft wne cjse d` wne x}al}jo |}dwes gjwj wa oeoa}t xadiweg mt j gjilfdil xadiwe}& js sdfeiwca}}uxwdai a` ui}efjweg gjwj ojt }esufw& fejgdil wa sumwfe muls wnjw cji me e~w}eoeft gd``dcufw wa `dig& a}cjuse seloeiwjwdai `jufws ."ID^$ a} leie}jf x}awecwdai `jufws .\diga|s$) D` wne ape}|}dwwei gjwj dsmaakkeexdil gjwj useg mt wne stsweo,s oeoa}t jffacjwa}& wne ca}}uxwdai cji cjuse stsweo diswjmdfdwdes)\dfg xadiwe}s j}dse |nei j xadiwe} ds useg x}da} wa didwdjfdrjwdai wa saoe kia|i swjwe& |ndcn ds xassdmfe disaoe x}al}joodil fjilujles) Wnet sna| wne sjoe e}jwdc menjpdau} js gjilfdil xadiwe}s& wnauln wnet j}efess fdkeft wa swjt uigewecweg)

    Jpadgdil gjilfdil xadiwe} e}}a}s

    J xaxufj} wecnidzue wa jpadg gjilfdil xadiwe}s ds wa use soj}w xadiwe}s) J soj}w xadiwe} wtxdcjfft uses}e`e}eice cauiwdil wa }ecfjdo ambecws) Saoe awne} wecnidzues dicfuge wne waomswaies oewnag jig wne facks/jig/kets oewnag)

    3

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    4/38

    Aie jfwe}ijwdpe ds wa use wne GdeNj}g oeoa}t jffacjwa}[:_& |ndcn pd}wujfft efdodijwes gjilfdil xadiwe} e}}a}s&js |eff js j pj}dewt a` awne} oeoa}t e}}a}s .fdke dipjfdg jig gaumfe `}ees$)

    Jiawne} jxx}ajcn ds wa use wne Maeno lj}mjle caffecwa}& j caise}pjwdpe lj}mjle caffecwa} wnjw }exfjcesswjigj}g oeoa}t jffacjwdai `uicwdais di C jig C++ |dwn j lj}mjle caffecwa}) Wnds jxx}ajcn caoxfeweftefdodijwes gjilfdil xadiwe} e}}a}s jfwalewne} mt gdsjmfdil `}ees& jig }ecfjdodil ambecws mt lj}mjlecaffecwdai)

    Di fjilujles fdke Bjpj& gjilfdil xadiwe}s cjiiaw accu} mecjuse wne}e ds ia oecnjidso wa e~xfdcdwftgejffacjwe oeoa}t) ]jwne}& wne lj}mjle caffecwa} ojt gejffacjwe oeoa}t& muw aift |nei wne ambecw ds iafaile} }ejcnjmfe `}ao jit }e`e}eices)

    :8$ Swjck Gaumw#dicfuge 6swgda)n9

    padg cnjile.${diw mu`[:_ ? {8;mu`[=_ +?

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    5/38

    @dig 3 |jts wa ojke wne jmape cage x}diw ^ =8 wdoes*

    J$ HJis|e} pe}t iej}diw d& i ? =8;`a} .d ? 8; d 6 i; d//${

    x}diw`.-^-$;

    wne cage ojt me oagd`deg fdke&

    diw d& i ? =8;`a} .d ? 8; yd 6 i; d//${x}diw`.-^-$;

    Wne jmape cage ds ldpdil ^ =: wdoes))) jit: cji ldpe wne e~jcw jis|e}))) d)e) wne cage |ndcn |dff x}diw wne ^=8 wdoes))) epei d o w}tdil))

    J$ diw d& i ? =8;

    `a} .d ? 78; d 6 i; d//${x}diw`.-^-$;

    diw d& i ? =8;`a} .d ? 8; d + i; d//${x}diw`.-^-$;

    J$ diw d& i ? =8;`a} .d ? 8; d 6 /i; d//${

    x}diw`.-^-$;

    :3$ Gtjijodc JffacjwdaiDs dw xassdmfe wa gtijodcjfft jffacjwe oeooa}t |dwnauw usdil jit a` ojffac&cjffac A} }ejffac1

    J$ojffac& cjffac j}e jff iaw xj}w a` c

    wnet j}e dicfugeg di j fdm}j}t

    sa d luess dw ds xassdmfe& wa njpe j use} ge`dieg ge`didwdai)

    J$ Wne}e,s jfsa jffacj& |ndcn gaes gtijodc jffacjwdai ai wne swjck)

    Jig C44 suxxa}ws doxfdcw gtijodc jffacjwdai .e)l) pj}djmfe feilwn j}}jts$)

    :7$ weff oe |newne} epe}t x}acess njs dwhs a|i nejx j}ej a} wnet jff j}e jffacjweg oeoa}t `}ao sjoe nejxai }ezuesw

    wnds ds ji AS/sxecd`dc gewjdf& muw uige} j ia}ojf PO AS sucn js Uid~) Fdiu~& Ojc AS ^ ewc& epe}t x}acessnjs dws a|i pd}wujf oeoa}t sxjce& |ndcn ds wtxdcjfft wne oj~douo jpjdfjmfe& d)e) 7 Lm ai j 3= mdw AS&jfwnauln wne}e ojt me saoe stsweo/|dge xafdct |ndcn x}epeiws tau `}ao jffacjwdil wne `uff 7 Lm)

    :5$ na| cji |e sjt wnjw sdrea`.$ ds ji axe}wa} jig iaw j `uicwdai

    5

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    6/38

    mjsdcjfft |jwhs wne gd`` di `uic jig axe}ja}js `j} js d kia| mawn j}e doxfeoeiweg usdil `uicwdai stiwj~

    J$ sdrea` ds j caoxdfe/wdoe axe}jwa}) D` tau |}dwe saoewndil fdke wnds2

    ~ ? sdrea`.diw$;

    |njw jcwujfft lews caoxdfeg ds2

    ~ ? 7; !! a} = a} > a} |njwepe}& gexeigdil ai tau} AS ewc

    Aie cfue wnjw sdrea` ds iaw j `uicwdai ds wnjw tau cji aodw wne m}jckews `a} mudfw/di wtxes& e)l)

    ~ ? sdrea` diw;

    :0$ Casw/]eguceg s|jx |dwnauw j weoxa}j}t pj}djmfepadg ojdi.${diw d?:8&b?=8;b ? d+b/.d?b$;!!s|jxxdil |dwnauw j weoxa}j}t pj}djmfe

    :$ !" Disu}jice a` g}dpe} / usdil faldcjf axe}jwa}s "!ojdi. ${

    cnj} se~& os ;diw jle ;

    x}diw` . -Eiwe} jle& se~& oj}dwjf swjwus - $ ;scji` . -%g %c %c- jle& se~& os $ ;

    d` . . os ?? ,O,$ vv . os ?? ,U, se~ ?? ,O, jle 9 38 $ vv. os ?? ,U, se~ ?? ,@, jle 9 =5 $ $

    x}diw` . -G}dpe} ds disu}eg- $ ;efse

    x}diw` . -G}dpe} ds iaw disu}eg- $ ;

    :4$ j cai`usdai di pafjwdfe

    j }ejg dwhs useg di cjse |nei j pj}djmfe ds x}amjmfe wa me cnjileg `}ao auwsdge wne cage)))))sa |nei usegwne pj}djmfe |dff m| }e`e}eiceg `}ao dwhs jcwujf oeoa}t facjwdai))))))cji u xfr ldpe ji e~joxfe |ne}e jpj}djmfe di aie cage ds sna|i wa me cnjileg `}ao auwsdge wne cage))))))d o }ejfft cai`useg ape} pafjwdfe)

    0

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    7/38

    J$ pafjwdfe / usujfft j pafjwdfe pj}djmfe |dff me cnjileg mejcse .j$ dw,s snj}eg oeoa}t medil jccesseg mt w|aa} oa}e x}acesses a} wn}ejgs a} .m$ dw,s j pj}djmfe |ndcn |df me jccesseg mawn mt j `a}el}auig wjsk jig jidiwe}}uxw se}pdce }auwdie a} saoe kdig a` cjffmjck `uicwdai a} .c$ dw,s j nj}g|j}e }eldswe} |ndcn |dff cnjilegue wa nj}g|j}e jcwdpdwt .D!A& wdoe}s& ewc$)

    =8$ ds jffacj.$ xj}w a` swjigj}g fdm}j}t a} ds dw j lcc e~weisdai

    d }ejg wnjwfdm}j}t `uicwdai diwe}ijfft cjff wne stsweo cjffs |dwn wne nefx a` w}jx disw}ucwdai

    cji u xfr e~fxjdi mt ji e~joxfe na| wne jmape ds gaie usdil W]JX disw}ucwdai)

    Ds scaxe }esafuwdai axe}jwa} 22 xe}odssdmfe di JISD C wa jccess lfamjf pj}djmfes |dwn wne sjoe ijoe js facjfpj}djmfes))))a} j}e wnet aift jpjdfjmfe di C++

    J$ jffacj ds jpjdfjmfe |dwn oasw oage}i C caoxdfe}s muw D,o iaw su}e d` dw,s xj}w a` wne C swjigj}g) Saoej}cndwecwu}es use W]JX disw}ucwdais a} sa`w|j}e diwe}}uxws wa ojke stsweo cjffs / wnds ds ndlnft j}cndwecwu}e/sxecd`dc wnauln sa tau cji,w ojke jit leie}jf swjweoeiws jmauw wnds) Iaojfft wne x}al}jooe} gaes iwacj}e js wnet |dff busw ojke swjigj}g fdm}j}t cjffs) Wne scaxe }esafuwdai axe}jwa} 22 ds aift jpjdfjmfe di C++)

    =:$ sw}ucw

    sw}ucw weox{diw d;`fajw `;;!!ia|sw}ucw weox "xw}?.sw}ucw weox"$ojffac.sdrea`.sw}ucw weox$+7$;`}ee.xw}$;

    ia| na| oucn oeoa}t |dff lew `}eeg

    : sw}ucw weox jp}djmfewawjf jffacjweg

    jcwujfft wnds |fg me oa}e pcfej}ee} d` u xfr weff oe |jw gaes wne joofac keex wa keex wne cauiw `a} joauiwa` oeoa}t jffacjweg)))))ia a` ambecws a` wne gjwj wtxe a} ia a` mtwes a` oeoa}t jffajcweg

    J$ ojffac gaesi,w kia| jitwndil jmauw |njw tau,}e jffacjwdil jxj}w `a}o wne sdre di mtwes& sa di tau}e~joxfe tau,}e x}amjmft jffacjwdil jig `}eedil := mtwes .jfwnauln dw,s AS/sxecd`dc& sa dw ojt me j gd``e}eiwpjfue$)

    ==$ Xj}joewe} xjssdil wa wne swjckDs dw lu}jiweeg wnjw xj}joewe}s a` wne `uicwdai cjff j}e xjsseg wa wne swjck di }dlnw wa fe`w a}ge}1See wne cage2padg `.diw j&diw m${ x}diw`.-%gVw%g-&j&m$;diw ojdi.${ diw ~?3;`.++~&~++$;}ewu}i 8;

    Di a}ge} wa kia| wne auwxuw a` wne cage&aie ieeg wa kia| |njw ds wne a}ge} a` xj}joew} xjssdil wa wne swjck)Ds dw sxecd`deg di wne JISD C swjigj}g wnjw |neiepe} j `uicwdai cjff ds ojge &xj}joewe} j}e xjsseg `}ao }dlnwwa fe`w)A} dw gexeigs ai wne swjck doxfeoeiwjwdai a` wne uige}ftdil axe}jwdil stsweo1

    J$ D wndik dw gexeigs uxai caoxdfe}**lcc&cc&c++&l++ xusnes wne j}luoeiws a` `uic) `}ao ]DLNW wa FE@W))sa dw snug x}diw 2

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    8/38

    5 3

    w}t wnds2x}diw`.-%g %g-++~~++$;auwxuw25 3 d)e sjoe js jmape .js `j} js d kia|$***

    =3$ Wne x}amfeo ds wa x}diw -Neffa \a}fg- ai wne sc}eei |dwnauw usdil jit fdm}j}t `uicwdai fdke x}diw`&xuws&cauwewc)1

    J$ diw ojdi. diw j}lc & cnj} "" j}lp ${diw `g;cnj} " sw} ? -Neffa \a}fgVi-;d`. .`g ? axei. j}lp[:_ & AQ\]AIFT $ $ 6 8 ${xe}}a}.-Axei-$;}ewu}i /:;d`. |}dwe. `g & sw} & sw}fei.sw}$ $ 6 8 ${

    xe}}a}.-\}dwe-$;}ewu}i /:;}ewu}i 8;

    ]ui js2)!j)auw !gep!xws!3:=a})!j)auw !gep!wwt:

    Wnds |dff ga ai "id~)

    J$ ai Fdiu~ ~>0 |dwn lcc tau cji ga wnds2

    padg ojdi.padg$ {jso .-diw ':=>- 22 -j-.7$& -m-.:$& -c-.-Neffa \a}fgVi-$& -g-.:=$$;

    =7$ \njw,s wne auwxuw1#dicfuge 6swgda)n9

    diw dic.diw d${ }ewu}i ++d;

    diw ojdi.${diw j&m&c;j ? m ? c ? 8;

    |ndfe. ++j& j?dic.j$& j 6 3${

    |ndfe. m?:& c?dic.c$& c 6 3$++m& m?dic.m$& ++m;x}diw`.-%g %g %gVi-& j&m&c$;

    >

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    9/38

    =5$ \ndfe di j s|dwcnW}t wnds auw))))

    diw d ? k ? =;s|dwcn .d${cjse : 2 d++;

    m}ejk ;|ndfe . d *? :8 ${cjse = 2 d++ ;m}ejk ;cjse 3 2 k++ ;m}ejk ;

    x}diw` . - %gVw%gVi- & d & k $ ;

    Ds dw ladil wa caoxdfe111D` ia |nt1D` tes1 |njw |dff me wne auwxuw1

    e~xfjdi Na| dw |a}ks111

    J$ @d}sw wndil wnjw x}al}jo ldpes wne caoxdfe w doe e}}a}) Mecjuse U cji,w jssdli aie pj}djmfe wa awne}pj}djmfe jw gecfj}jwdai wdoe)D` tau gecfj}e js diw d& k ; d? k ? =;wnei wnjw x}al}jo |dff x}diw 3.d?3$ & 3.k?3$ ) Di s|dwcn dw `d}sw epjfujwe wne diwele} e~x}essdai jig cnecks `a}wne ca}}esxaigdil cjse) D wndik dw gaesi,w ojwwe} |njwepe} dw ds wne}e pjfdg swjweoeiws) Sa ne}e ojwcnes cjse= ) Sa d ds dic}eoeiweg jig pjfue ia| 3) M}ejk |dff m}dils wne caiw}af wa auw a` |ndfe swjweoeiws) Sa ia| dw|dff e~ecuwe |njwepe} swjweoeiws j}e wne}e) sa k ds dic}eoeiweg jig pjfue mecaoe 3)Ia| wnds m}ejk |dff m}dils caiw}af wa auw a` wne s|dwcn swjweoeiw) Ia| wne x}diw` |dff x}diw d jig k pjfues js 3 &3)

    J$ E}}a}@d}swft diw d?k?=;Ieegs wa me ojge diw k;

    diw d?k?=;Mt ojkdil wnese cnjiles |e |dff lew wne e}}a} a}xnjieg cjse `a} cjse =2d++

    =0$ Fd`e |dwnauw sdrea`Z)D` tau j}e iaw njpdil j sdrea` axe}jwa} di C& na| |dff tau lew wa kia|wne sdre a` ji sw}ucw1sw}ucw xadiw {fail ~& t;;

    J$ sw}ucw xadiw" x;

    sdre ? .cnj}"$.x+:$ / .cnj}"$x;

    J$ wtxege` sw}ucw j{diw j;diw m;diw c;diw g;cnj} j}}jt[7_;fail fail e; sw;ojdi.${

    4

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    10/38

    sw js ;x}diw`.-%g Vi-&.diw$.js+:$ / .diw$.js$ $;x}diw`.-usdil sdrea` stscjff ? %gVi-&sdrea`.sw$$;

    =4 caoxfdjiw)

    #dicfuge 6swgda)n9diw ojdi .padg${diw j ? :8& m ? 5;diw c;c ? j!!"

    !!"!m;x}diw`.-%g-&c$;}ewu}i 8;

    J$ Js `a} wne }e`e}eice wa C>4& !! |js iaw caisdge}eg js j caooeiw caisw}ucw di C>4) C44 ojkes dw j pjfdgcaooeiw caisw}ucw)

    J$ di C na|epe}wne fdie c ? j ! !")))"!m; snaufg epjfujwe js c ? j ! m; |ndcn ldpes =

    J$ Tux& = dw ds**

    J C44 caoxfdjiw caoxdfe} |aufg ldpe :8)

    =4$ \njw ds gd``e}eice mew|eei ge`die jig wtxege` di c1

    J$ wtxege` c}ejwes j ie| ijoe `a} j wtxe) #ge`die gaes j we~wujf }exfjceoeiw a` gjwj)

    @A} e~joxfe&

    wtxege`2wtxege` cnj}" CNJ]QXADIWE];CNJ]QXADIWE] j& m;

    :8

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    11/38

    Ne}e& mawn j jig m j}e a` wtxe CNJ]QXADIWE]) Sa& mawn |aufg me a` wtxe cnj}")

    #ge`die2#ge`die CNJ]QXADIWE] cnj}"CNJ]QXADIWE] j&m;

    Wnds ds wne sjoe js sjtdilcnj}" j&m;

    Ne}e& j ds a` wtxe cnj}"& |ndfe m ds a` wtxe cnj})

    J$ #ge`die ds njigfeg mt x}ex}acessa} jig wtxege` mt j caoxdfe})

    38$ swjwdc pj}djmfe|njw ds wne sdlid`dcjice a` swjwdc pj}djmfe 1 jig |nt ds dw sa doxa}wjiw di eomegeg . stsweo xe}njxs$x}al}joodil 1

    J$ swjwdc pj}djmfe ds swa}eg di NEJX jig iaw di SWJCK js jff wne awne} facjf pj}djmfes |dff me&wne}e`a}e dwnafgs dws pjfue di mew|eei `uicwdai cjffs

    3:$ Na| wa }esafpe scaxe di C

    na| cji D x}diw pjfue a` lfamjf pj}dmfe d disdge ojdi `uicwdai)

    #dicfuge 6swgda)n9

    diw d ? =88;

    padg ojdi.${diw d ? :88;x}diw`.-d ? %gVi-&d$;!" na| D cji jccess lfamjf d disdge ojdi `uicwdai "!

    J$ Usdil Scaxe ]esafuwdai 22Cjiw |e ga wnjw usdil Scaxe ]esafuwdai Axe}jwa}11

    J$ Wne}e ds ia scaxe }esafuwdai axe}jwa} di C)

    J$ \eff Luts D law

    #dicfuge 6swgda)n9

    diw d ? =88;

    padg ojdi.${diw d ? :88;{e~we}i diw d;x}diw`.-d ? %gVi-&d$;!" ia| dw x}diw pjfue a` lfamjf pj}djmfe d "!x}diw`.-d ? %gVi-&d$;!" ia| dw x}diwpjfue a` fjcjf d"!

    J$ Jiawne}& ezujfft gumdaus |jt2

    #dicfuge 6swgda)n9

    diw d ? =88;

    ::

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    12/38

    diw ojdi.${diw "xd ? d;diw d ? :88;

    x}diw`.-d ? %gVi-&d$;!" facjf d "!x}diw`.-d ? %gVi-& "xd$; !"lfamjf d"!

    3=$ padg ojdi.$

    \nei tau j}e |a}kdil |dwn Fdiu~& dws AK*** Muw |e kia| wnjw oasw x}al}jos a} jssdlioeiws gdscusseg ne}ej}e di caiwe~w a` |diga|s) Jig fdke jssdlioeiw di wnjw wn}ejg dw |js j swjig/jfaie x}al}jo)

    Sa Rjoji jig Xjuf)))Cji tau weff oe jit jgpjiwjle a` usdil diw ojdi.$ |nei di j swjig/jfaie x}al}jo)\nei tau njpe iawndil wa ga |dwn dws }ewu}i pjfue) Dw gaesi,w ojke jit gd``e}eice)

    J$ \nei tau |}dwe cage& di jit fjilujle& tau snaufg jf|jts me |}dwdil dw wa me js xa}wjmfe js ds }ejsaijmftxassdmfe) Tau njpe ia |jt a` kia|dil na| a} |ne}e wnjw cage ds ladil wa me useg di wne `uwu}e) Cage dse~xeisdpe wa |}dwe jig ojdiwjdi& sa |e |jiw dw wa me a` laag zujfdwt jig js ejst js xassdmfe wa ojdiwjdi) Dia}ge} wa ga wnds |e ieeg wa jgaxw laag sa`w|j}e eildiee}dil x}jcwdces& jig w|a a` wnese x}jcwdces j}e

    jgne}dil wa fjilujle swjigj}gs jig |}dwdil xa}wjmfe cage .saoe ape}fjx mew|eei wnese w|a$)

    Sa ldpei wne cnadce mew|eei |}dwdil wne swjigj}g& xa}wjmfe diw ojdi.$ jig wne iai/swjigj}g iai/xa}wjmfepadg ojdi.$& jig ldpei wnjw wne}e ds pd}wujfft ia gd``e}eice di wne joaiw a` e``a}w }ezud}eg& |nt |aufg jitaiecnaase wne fjwwe} 1 Wne aift e~xfiijwdai D cji see ds wnjw wne xe}sai |na |}dwe padg ojdi ds edwne} cfuefess&fjrt a} busw gaesi,w cj}e jmauw cage zujfdwt dssues) \njwepe} wne }ejsai wnauln& D |aufgi,w nd}e wneo)

    J$ Tes xa}wjmfdwt))))Muw busw `a} wne sjke a` j}luoeiw& D iepe} }ebecws jit xe}sai ai wnese }ejsais) D njpe epei nd}egx}al}jooe}s wnjw j}e iaw caoxfeweft `jodfdj} |dwn wne stiwj~ a` C!C++) Muw wnjw d cji wejcn wneo) Wnet ouswnjpe laag jijftwdcjf skdffs jig x}amfeo safpdil skdffs& jig laag axe}jwdil stsweo caicexws) D wndik wnjw,s jffieegeg `a} j laag C++ gepefaxe})

    J$ Tes& muw wnei tau,}e iaw nd}dil j C x}al}jooe}& tau,}e nd}dil j w}jdiee& sa wne c}dwe}dj |aufg me gd``e}eiw)D` D,o nd}dil j C x}al}jooe} D gai,w e~xecw wa njpe wa wejcn wneo pe}t mjsdc swu`` jmauw C x}al}jodil me`a}e

    wnet mecaoe use`uf) Jig mesdges& wne sa}w a` xe}sai |na |}dwes -padg ojdi- ds x}amjmft cfuefess di ojitawne} }elj}gs waa

    J$ padg ojdi.padg$ / wne \}ail Wndil

    Mecjuse wne swjigj}g sjts sa).Wa |ndcn wne jis|e} ds usujfft a` wne `a}o -muw dw |a}ks `a} oe*-$

    Mecjuse wne swj}wux }auwdies wnjw cjff ojdi caufg me jssuodil wnjw wne }ewu}i pjfue |dff me xusneg aiwa wneswjck) D` ojdi.$ gaes iaw ga wnds& wnei wnds caufg fejg wa swjck ca}}uxwdai di wne x}al}jo,s e~dw sezueice& jigcjuse dw wa c}jsn).Wa |ndcn wne jis|e} ds usujfft a` wne `a}o -muw dw |a}ks `a} oe*-$

    Mecjuse tau j}e fdkeft wa }ewu}i j }jigao pjfue wa wne dipakjwdaieipd}aioeiw) Wnds ds mjg& mecjuse d` saoeaie |jiws wa cneck |newne} tau} x}al}jo `jdfeg& a} wa cjff tau}x}al}jo `}ao j ojke`dfe& wnei wnet |ai,w me jmfe wa luj}jiwee wnjw j iai/re}a }ewu}i cage doxfdes `jdfu}e).Wa |ndcn wne jis|e} ds usujfft a` wne `a}o -wnjw,s wned} x}amfeo-$)

    SAU]CE2 nwwx2!!use}s)jme})jc)uk!jub!padgojdi)snwof

    33$ \njw ds wne sojffesw `uicwdai di C1

    J$ diw ~.padg$ { }ewu}i 8;

    :=

    http://users.aber.ac.uk/auj/voidmain.shtmlhttp://users.aber.ac.uk/auj/voidmain.shtml
  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    13/38

    J$ A} d` dw gaesi,w ieeg wa ga jitwndil use`uf)))padg ~.padg$ {

    35$ Caooai wa C jig C++2

    :)$ \njw ds wne pjfue a` d di jit a` wne `affa|dil e~x}essdais2d ? d++;d++ + ++d ewc)

    Jis / Wnds ds uige`dieg menjpdau}) Uige`dieg gaes iaw oeji caoxdfe} |dff leie}jwe ji e}}a}) Dw busw oejiswnjw caoxdfe} ds `}ee wa njigfe dw jit|jt) Sa tau |dff see auwxuw muw tau cji iaw }eft ai dw) @a} oa}e di`a ai dw&faak jw sezueice xadiws) Jfsa }e`e} wne Swjigj}gs)

    =)$ \njw gjwj wtxe snaufg wne `uicwdai ojdi.$ }ewu}i1

    Jis / Jcca}gdil wa wne C jig C++ swjigj}gs wne ojdi.$ `uicwdai snaufg }ewu}i ,diw,) Jig d` tau j}e iawxjssdil caoojig fdie j}luoeiws& usediw ojdi . padg $)

    30$ Wne G&E Xadiws a` diwe}esw:) Difdidil |js caisdge}eg doxa}wjiw `a} wne uwdfdwt a` cfjsses) Wne}e`a}e& wne dssue |js oa}ena|wa x}apdge dwwnji |newne}wa x}apdge dw)

    Wne caoxdfe} kia|s mesw d` dw njs meei x}al}jooeg wa difdie jig dw njs j iawdai a` wdoe!sxjce axwdodrjwdaiwnjw jl}ees odie.Mbj}ie,s$)

    @u}wne}oa}e& wecnidzues wnjw }ezud}e lfamjf jijftsds& sucn js juwaojwdc difdidil |dwnauw use} suxxa}w& weigiaw wa scjfe |eff wa pe}t fj}le x}al}jos)

    =) D .Mbj}ie& `}ao ia| ai xfejse caisdge} dw doxfdcdw$ x}e`e} ijoe ezudpjfeice ape} sw}ucwu}jf ezudpjfeicemecjuse D caisdge} dw wne sj`esw jig cfejiesw oagef .`a} fdikjle$) D |js wne}e`a}e xfejseg wa `dig wnjw wndsgecdsdai gdgi,w lew oe diwa caoxjwdmdfdwt x}amfeos |dwn C jig gdgi,w caoxfdcjwe wne x}apdsdai a` fa|/fepefse}pdces)

    Wnds fjwe} l}e| diwa wne ,Aie/ge`didwdai }ufe2, epe}t `uicwdai& pj}djmfe& wtxe& caiswjiw& ewc)& di C++ njs e~jcwftaie ge`didwdai)

    3) Wn}auln wne jccexwjice a` wne C fdike} cjoe jiawne} }ufe a` wnuom `a} wne gepefaxoeiw a` C++2 C++ dsbusw aie fjilujle di j stsweo jig iaw j caoxfewe stsweo) Di awne} |a}gs& C++ jccexws wne }afe a` jw}jgdwdaijf x}al}joodil fjilujle |dwn j `uigjoeiwjf gdswdicwdai mew|eei wne fjilujle& wne axe}jwdilstsweo& jig awne} doxa}wjiw xj}ws a` wne x}al}jooe},s |a}fg)

    Dw ojkes dw esseiwdjf wnjw j C++ x}al}jo `}jloeiw cji cjff x}al}jo `}jloeiws |}dwwei di awne} fjilujles.fdke C& @a}w}ji$ jig wnjw j C++ x}al}jo `}jloeiw cji dwsef` me cjffeg mt x}al}jo `}jloeiw |}dwwei di awne}fjilujles)

    7) Ape} wne tej}s& ot e~xe}deice jig wnjw a` ot caffejlues njs meei wnjw fdik cjxjmdfdwt ds oucn oa}edoxa}wjiw wnji sau}ce caoxjwdmdfdwt)

    5) \nei wnds |js diw}aguceg diwa C |dwn Cfjsses .x}egecessa} a` C++$& wne fjilujle gdgi,w njpe }e`e}eices&jig C++ ma}}a|eg dws we}odiafalt `}ao Sdoufj }jwne} wnji `}ao Sojffwjfk)

    0) C |dwn cfjsses diw}aguceg wne iawdai a` `.padg$ `a} j `uicwdai ` wnjw wjkes ia j}luoeiws js j caiw}jsw wa `. $wnjw di C gecfj}es j `uicwdai wnjw cji wjke jit iuome} a` j}luoeiws a` jit wtxe |dwnauw jit wtxe cneck) Otuse}s saai caipdiceg oe& na|epe}& wnjw wne `.padg$ iawjwdai |jsi,w efeljiw& jig wnjw njpdil `uicwdaisgecfj}eg `.$ jccexw j}luoeiws |jsi,w diwudwdpe) Caisezueiwft& wne }esufw a` wne e~xe}doeiw |js wa njpe `.$oeji j `uicwdai ` wnjw wjkes ia j}luoeiws& js jit iapdce |aufg e~xecw) Dw waak suxxa}w `}ao mawn Gaul

    :3

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    14/38

    OcDf}at jig Geiids ]dwcnde `a} oe wa mudfg ux wne cape}jle wa ojke wnds m}ejk `}ao C) Aift j`we} wnet usewne |a}g jmaodijwdai jmauw `.padg$ gdg D gj}e ldpe `.$ wne ampdaus oejidil) Na|epe}& wa wnds gjt& C,s wtxe}ufes j}e oucn oa}e fj~ wnji C++,s& jig JISD C jgaxweg ,wne jmaodijmfe `.padg$, `}ao C |dwn Cfjsses)

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    15/38

    Jff sjdg jig gaie& wnds ds ji afg caicexw jig uifess tau j}e x}al}joodil jw j pe}t fa|e}/fepef& sjt ojkdilji AS& tau snaufg iaw |a}}t jmauw wne iej} jig `j} xadiwe}s)

    J$ dw |js useg di afg gjts) Jccwujfft @j} xadiwe} wtxes ga iaw e~dsw `a} 3= mdw caoxdfe}s)Dw |js j iai/swjigj}ge~weisdai aift x}eseiw di :0 mdw C caoxdfe}s ai diwef xfjw`a}os) Wne aift }ejsai xeaxfe dipeiweg wne `j}xadiwe} ds mecjuse Diwef cjoe ux |dwn wnds m}jdi gjojleg seloeiweg j}cndwecwu}e |nei wnet gesdlieg wne

    >8>> jig wne `j} xadiwe} |js j njck `a} C caoxdfe}s wa lew j}auig jccessdil oeoa}t di jiawne} seloeiw)3= mdw caoxdfe}s see wne oeoa}t js j `fjw oeoa}t oagef |dwn iaie a` wnds seloeiweg iaiseise& sa wne}e,sia ieeg `a} wneo wa use wne `j} ket|a}g jitoa}e)

    Jig di @fjw oeoa}t oagef wne}e ds ia ieeg `a} @j} Xadiwe} js di `fjw oeoa}t oagef Jff cjffs j}e IEJ]& Jffjgg}esses j}e 3= mdws& Seloeiw }eldswe}s iepe} }efajgeg& Seloeiw ape}}dges iepe} useg) Muw di wneseloeiweg oeoa}t oagef wne}e j}e sexe}jwe seloeiws `a} Jgj cage& Lfamjf Jgj gjwj& ]WS cage& ]WSgjwj& Swjck& Nejxs jig Caffecwdais jig jff jgg}esses j}e :0+3= mdws jig cjffs `}ao Jgj wa ]WS uses wne `j}xadiwe})

    3>$ ``fusn.$;|njw ds g use a` ``fusn.$; di c1na| i |ne}e snaufg |e use dw1

    J$ ``fusn ds useg wa `fusn wne sw}ejo dws gecfj}jwdai ds diw ``fusn.@DFE "sw}ejo$;d` wne ldpei sw}ejo njs mu``e}ega!x wnei ``fusn |}dwes wnjw a!x di jssacdjweg `dfes )dw njs ia e``ecw ai ji uimu``e}eg sw}ejo )

    ai success dw }ewu}is 8 efse dw }ewu}is EA@)

    J$ Laag jis|e}) Iawe jfsa wnjw ``fusn snaufg iepe} me cjffeg ai ji dixuw sw}ejo& e)l) ``fusn.swgdi$ ds dipjfdgjig ojt cjuse uix}egdcwjmfe menjpdau})

    J$ @uff di`a)IJOE

    ``fusn / `fusn j sw}ejo

    STIAXSDS

    #dicfuge 6swgda)n9

    diw ``fusn.@DFE "sw}ejo$;

    GESC]DXWDAI

    D` sw}ejo xadiws wa ji auwxuw sw}ejo a} ji uxgjwe sw}ejo di |ndcn wne oasw }eceiw axe}jwdai |js iaw dixuw&``fusn.$ cjuses jit ui|}dwwei gjwj `a} wnjw sw}ejo wa me |}dwwei wa wne `dfe& jig wne swQcwdoe jig swQowdoe`defgs a` wne uige}ftdil `dfe j}e oj}keg `a} uxgjwe)

    D` sw}ejo ds j iuff xadiwe}& ``fusn.$ xe}`a}os wnds `fusndil jcwdai ai jff sw}ejos `a} |ndcn wne menjpdau} dsge`dieg jmape)

    ]EWU]I PJFUE

    Uxai success`uf caoxfewdai& ``fusn.$ }ewu}is 8) Awne}|dse& dw }ewu}is EA@ jig sews e}}ia wa digdcjwe wne e}}a})

    34$ \njw ds wne gd``e}eice mew|eei lewcn.$ jig lewcne.$

    J$ LEWCN.$222Wnds ds j `uicwdai wnjw lews j cnj}jcwe} `}ao ketmaj}g& gaes iaw ecna wa sc}eei)

    LEWCNE.$222Wnds ds j `uicwdai wnjw lews j cnj}jcwe} `}ao wne ketmaj}g& ecnaes wa sc}eei)

    78$ dgdaojwdc cage\eff Luts wnds ds ji dgdaojwdc cage di C

    |ndfe."sw}:++??"sw}=++$

    :5

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    16/38

    ;naxe u cji jis|e}*** |jw gaes wne jmape cage leie}jwes 111 iawe wnds ds iaw ji ejst d luess

    J$ Dw,s busw j we}se afg/`jsndaieg |jt a` ` digdil wne `d}sw iai/ojwcndil cnj}jcwe} di w|a sw}dils)

    D` tau sumswdwuwe ? `a} ?? wnei dw mecaoes j we}se afg/`jsndaieg |jt a` doxfeoeiwdil sw}cxt .D wndik wnds ojtepei njpe meei di wne `d}sw egdwdai a` K] 1$)

    73$ Pjfue .caoxuwe} scdeice$

    @}ao \dkdxegdj wne `}ee eictcfaxegdj

    Di caoxuwe} scdeice& j pjfue ds j sezueice a` mdws wnjw ds diwe}x}eweg jcca}gdil wa saoegjwj wtxe) Dw dsxassdmfe `a} wne sjoe sezueice a` mdws wa njpe gd``e}eiw pjfues& gexeigdil ai wne wtxe useg wa diwe}x}ew dwsoejidil) @a} diswjice& wne pjfue caufg me ji diwele}a}`fajwdil xadiw pjfue& a} j sw}dil)

    Saoe kdigs a` pjfue j}e caooai wa oasw x}al}joodil fjilujles .e)l)& pj}daus kdigs a` iuome}}ex}eseiwjwdais$& |ndfe awne}s j}e fess caooaift suxxa}weg .e)l)& Xjscjf suxxa}ws j sew wtxe$)

    Di C2 F/pjfue jig }/pjfue

    Saoe fjilujles use wne dgej a`f/pjfue jig }/pjfue) F/pjfues j}e pjfues wnjw njpe jgg}esses& oejidilwnet j}e pj}djmfes a} ge}e`e}eiceg }e`e}eices wa j ce}wjdi xfjce) ]/pjfue ds edwne} f/pjfue a} iai/f/pjfue jwe}o aift useg wa gdswdiludsn `}ao f/pjfue) Di C& wne we}o f/pjfue a}dldijfft oejiw saoewndil wnjw caufg mejssdlieg .caodil `}ao fe`w/pjfue& digdcjwdil dw |js ai wne fe`w sdge a` wne ? axe}jwa}$& muw sdice ,caisw, |jsjggeg wa wne fjilujle& wnds ia| ds we}oeg j ,oagd`djmfe f/pjfue,)

    Ji f/pjfue ds ji e~x}essdai wnjw gesdlijwes .}e`e}s wa$ ji ambecw) J iai/oagd`djmfe f/pjfue ds jgg}essjmfe& muwiaw jssdlijmfe) J oagd`djmfe f/pjfue jffa|s wne gesdlijweg ambecw wa me cnjileg js |eff js e~jodieg) Ji }/pjfue ds jit e~x}essdai wnjw ds iaw ji f/pjfue& dw }e`e}s wa j gjwj pjfue wnjw ds swa}eg jw saoe jgg}ess dioeoa}t)

    77$ |njw ds ge`e}eice mew|eei ge`didwdai gecfj}jwdai a` e~we}ijf pj}djmfes1

    J$ e~we}i diw d; !! gecfj}jwdai .usujfft di j )n `dfe$

    diw d; !! ge`didwdai .usujfft di j )c `dfe$

    75$ cji ie/aie xfr weff oe wne gd``e}eice mew|eei e~ecuwjmfe jig ambecw `dfe 111

    J$ Mawn caiwjdi mdij}t cage)Ji e~ecuwjmfe ds caoxfewe) Jff stomafs j}e ge`dieg di ji e~ecuwjmfe .e~cexw stomafs doxa}weg `}aogtijodc fdm}j}des& muw wnjw,s jiawne} swa}t$)Ji e~ecuwjmfe ds uige}swjigjmfe mt wne uige}ftdil axe}jwdil stsweo)Ji e~ecuwjmfe }ex}eseiws j caoxfewe }ejgt/wa/use caoxdfeg jxxfdcjwdai)

    Ji ambecw `dfe }ex}eseiws j xj}w a` ji jxxfdcjwdai) Dw caiwjdis wne cage a` j `e| `uicwdais& muw ds .usujfft$dicaoxfewe) d)e) dw uses `uicwdais a} e~we}ijf pj}djmfes |ndcn dw gaesi,w ge`die& jig sa& dw ousw me fdikeg .|dwnj fdike}$ wa awne} ambecw `dfes caiwjdidil wne ge`didwdais a` wnese uige`dieg stomafs di a}ge} wa x}aguce jie~ecuwjmfe `dfe)

    Ji ambecw `dfe ojt njpe j pe}t sxecd`dc iai/xa}wjmfe `a}ojw suxxa}weg mt aift j `e| caoxdfe}s .esxecdjfftuige} \diga|s& muw wnjw,s zudwe `jfse ai awne} axe}jwdil stsweos$) Dw ojt iaw me uige}swaag gd}ecwft mt wneuige}ftdil axe}jwdil stsweo& wnauln uige} UID^ stsweos |dwn EF@ ambecw `dfes& e~ecuwjmfes ambecw `dfes jffwnds ds wdlnwft }efjweg jig wne C fdike} ds jfoasw js }efjweg wa wne AS wnji wne e~ecuwjmfe gtijodc fdike})Ambecw `dfes j}e use`uf wa }ex}eseiw sojff xj}wdjfft digexeigeiw xj}ws a` j x}abecw) Usujfft& wne}e ds j aie/wa/aie ojxxdil mew|eei j iai/nejge} sau}ce `dfe jig ji ambecw `dfe .|ndcn caiwjdis wne caoxdfeg mdij}t cage$)

    :0

    http://en.wikipedia.org/wiki/Computer_sciencehttp://en.wikipedia.org/wiki/Data_typehttp://en.wikipedia.org/wiki/Integerhttp://en.wikipedia.org/wiki/Floating_pointhttp://en.wikipedia.org/wiki/Stringhttp://en.wikipedia.org/wiki/Programming_languagehttp://en.wikipedia.org/wiki/Pascal_(programming_language)http://en.wikipedia.org/wiki/Memory_addresshttp://en.wikipedia.org/wiki/Computer_sciencehttp://en.wikipedia.org/wiki/Data_typehttp://en.wikipedia.org/wiki/Integerhttp://en.wikipedia.org/wiki/Floating_pointhttp://en.wikipedia.org/wiki/Stringhttp://en.wikipedia.org/wiki/Programming_languagehttp://en.wikipedia.org/wiki/Pascal_(programming_language)http://en.wikipedia.org/wiki/Memory_address
  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    17/38

    Wnds stsweo jffa|s }emudfgdil j x}abecw |dwn j sdoxfe caoxdfjwdai a` sau}ce `dfes njpdil meei oagd`deg muwiaw awne}s)

    Ambecw `dfes j}e jfsa j oeji wa gdsw}dmuwe fjilujle/digexeigeiw" .muw xfjw`a}o/gexeigeiw$ swjwdc fdm}j}des&x}ax}edwj}t a} iaw)J swjwdc fdm}j}t `dfe ds iawndil oa}e wnji j muicn a` ambecw `dfes di ji j}cndpe& axwdaijfft caiwjdidil j nejge}`a} `jsw stomaf faakux)

    "fjilujle digexeigeiw oejis wnjw ambecw `dfes j}e caoxdfeg mdij}t cage |ndcn cji caoe `}ao jsseomft&@a}w}ji& C& C++& Jgj& Oagufj& Xjscjf& ewc) sau}ce `dfes& jig wnet cji l}jce`ufft me fdikeg walewne}*

    70$ fdikeg fdswci jitmagt weff oe wne x}jcwdcjf jxxfdcjwdais a` fdikeg fdsw))

    J$ Wne}e j}e ojit jxxfdcjwdais a` fdikeg fdsws)@a} e~joxfe di fdiu~ ke}ief tau njpe x}acess wjmfe |ndcn ds doxfeoeiweg js fdikeg fdsw) Wne iuome} a`x}acesses di wne stsweo ds gtijodc jig ke}ief cjiiaw jffacjweg wne oeoa}t `a} wnese swjwdcjfft) Sa |neiepe} ie| x}acess lews sxj|ieg & dws dise}weg diwa wne fdikeg fdsw)

    Wne zueues jw iew|a}k }auwe}s& wne epeiws di epeiw mjseg sdoufjwdai ))ewc uses fdikeg fdsws)

    7

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    18/38

    !" Wnds cage uses ^A] wa s|jx wne pjfues jw xadiwe}s "!

    J$ Tau gai,w ieeg wa s|jx wne pjfues& busw s|jx wne xadiwe}s& e)l)

    x: ? ~;x= ? t;

    !! ia| s|jx wneo

    x: ? t;x= ? ~;

    Wnds wecnidzue ds xj}wdcufj}ft doxa}wjiw |nei tau,}e s|jxxdil saoewndil oucn fj}le} wnji ji diw& sdice dwoejis wnjw tau gai,w ieeg wa caxt jit gjwj)

    74$ wne}e } 0 wakeis))):$ket|a}gs&=$dgeiwd`de}s3$caiswjiws7$sw}dil fdwe}jfs5$axe}jwa}s

    0$sexj}jwa}s

    58$ wn}ejg & x}acess)))1|jw ds wne gd``e}jice mew|eei wn}ejg x}acess)))))d` jit)))1

    J$ Wn}ejgs cae~dsw di j sdilfe x}acess,s oeoa}t sxjce& jig j}e wne}e`a}e oucn oa}e wdlnwft cauxfeg wnjix}acesses& |ndcn ejcn njpe wned} a|i oeoa}t sxjce

    J$ X}acess2 Wne X}acess ds ji diswjice a` j x}al}jo& j sdilfe x}acess cji njigfe gd``e}eiw x}al}jos a}gd``e}eiw x}acesses cji njigfe j sdilfe x}al}jo)))

    Wn}ejg2 J wn}ejg ds sezueice a` caiw}af |dwn di wne x}acess)))j wn}ejg caiwjdis dws a|i swjck jig jff awne} lfamjf pj}djmfes& `dfe ges ewc))) cij me snj}eg `}ao wne x}acess)J X]ACESS CJI CAIWJDI OUFWDXFE IA)A@ WN]EJGS))

    5:$ j++ Jig ++j cai`usdaiCji Sm weff oe wne jis a` wne `affa|dil cage usdil Wu}ma c2/

    #dicfuge6swgda)n9diw ojdi.${diw j?8&m;m?j++ + ++j + ++j + ++j + ++j + j++;x}diw`.-%g %g-&j&m$;}ewu}i 8;

    J$ Epei d` tau kia| wne caoxdfe}& wne }esufw ds swdff uige`dieg) Wne sjoe caoxdfe} ojt leie}jwe gd``e}eiwmenjpdau} di gd``e}eiw caiwe~ws a} |dwn gd```e}eiw caoojig fdie s|dwcnes .e)l) axwdodsjwdai fepef$)

    Sa wne jis|e} swjigs2 wne }esufw ds uige`dieg& epei d` tau kia| |ndcn caoxdfe} ds medil useg)

    5=$ #dicfuge6swgda)n9!"wnds x}al}jo fdsws jff wne x}doe ia) mew|eei = wa 388"!ojdi.${diw j&m;

    `a}.j?=;j6?388;j++${`a}.m?=;m6?j/:;m++$

    :>

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    19/38

    {d`.j%m??8$

    m}ejk;d`.m??j$x}diw`.-%g Vi-&j$;

    53$ cji jit aie xfr nefx oe **** }elj}gs caooj))`d}swft& d |aufg fdke wa kia|))) |nejwne} -&- ds ji axe}jwa} a} sexj}jwa})))1 a} mawn)) a} iaie1

    secaigft& cji jit aie weff wnds x}al}jo menjpdau} xfejse)))1

    diw ojdi.${diw j ? 5& m ? :8& c& g;c ? j& m;g ? .j& m$;x}diw`.-c ? %g g ? %g-& c& g$;

    c ? 5 g ? :8

    d jo cai`usdil |dwn g; na|r g ds }exfjceg |dwn :8 1111

    J$ Dw gexeigs ai caiwe~w / j caooj cji me j sexj}jwa} a} ji axe}jwa}) \nei dw,s ji axe}jwa} wne FNS dsepjfujweg jig gdscj}geg jig wne ]NS ds epjfujweg jig }ewu}ieg

    J$ ]ejsai2caisdge} wne swjweoeiw

    c?j&m;

    sdice caooj axe}jwa} ds njpdil fa|e} x}da}dwt wnji jssdlioeiw axe}jwa}sa dw ds epjfujweg js

    .c?j$&m;!!`d}sw jssdlioeiw wnei caooj jig neice wne }esufw ds 5

    di u} secaig swsweoeiwg?.j&m$;!!! .$ ds njpdil l}ejwe} x}da}dwt wnji wne ?.jssdlioeiw$ axe}jwa}sa `d}sw .j&m$ ds epjfujweg |ndcn }ewu}is wne pjfue a` -m-jig wnei wnds pjfue ds jssdlieg wa g jig neice wne }esufw)

    57$ Na| wa jgg w|a iuome}s |dwnauw usdil j}dwnoewdc axe}jwa}s 1

    Ne}e ds na| tau cji jgg w|a iuome}s |dwnauw usdil jit j}dwnoewdc axe}jwa}s) Wne cage uses mdw|dseaxe}jwa}s) Wnds cage x}ewwt oucn doxfeoeiws j `uff jgge} |ndcn jggs wn}ee mdws jig }ewu}is w|a mdws . j cj}}tjig j suo$)

    J$ #dicfuge 6swgda)n9diw jgg.diw j& diw m${

    d` .*j$ }ewu}i m;efse}ewu}i jgg..j m$ 66 :& j Y m$;

    diw ojdi.${x}diw`.-Eiwe} wne w|a iuome}s2Vi-$;diw j&m;scji`.-%g-&j$;scji`.-%g-&m$;

    :4

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    20/38

    x}diw`.-Suo ds2 %g-&jgg.j&m$$;

    55$ Cji jitaie sullesw oe wne mesw |jt wa `dig faax di j fdikeg fdsw)Faax ne}e oejis dw cji me cd}cufj} jw jit iage d)e wne fjsw iage cji me xadiwdil wa jit iage)

    J$ Wjke w|a xadiwe}s wa w}jpe}se wne fdsw)Ojke `d}sw xadiwe} wa w}jpe}se fdsw swex mt swex jig secaig xadiwe} wa w}jpe}se wne sjoe fdsw w|a swexs jw jwdoe .}exejw w}jpe}sdil wne fdsw |dwn secaig xadiwe} uiwdf wne `d}sw xadiwe} }ejcnes eig a` fdsw$) Jw jit wdoe d`mawn xadiwe}s caiwjdi sjoe jgg}ess sjtdil wnjw wne}e ds j faax)D` tau law jit awne} |jts wa `dig faax& xfs few oe kia|)

    50$ Ldpe j aie/fdie C e~x}essdai wa wesw |newne} j iuome} ds j xa|e} a` =)

    J$ i ds ldpei iuome})))

    d` i. i/:$ ?? 8 ///////9 xa|e} a` =efse /////////9 iaw j xa|e} a` =

    J$ Tau} safuwdai `jdfs `a} i ? 8 .dw }ewu}is w }ue |nei dw snaufg }ewu}i `jfse& sdice 8 ds iaw j xa|e} a` =$)

    J mewwe} safuwdai2 i 9 8 .i .i / :$$ ?? 8;

    5

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    21/38

    auwxuw ds 3 = : |nt iaw : = 31

    J$ Wne auwxuw ds uige`dieg a} sjt caoxdfe} gexeigeiw)

    D wndik tau njpe }ui wne jmape cage ai Wu}ma C) Ia| w}t }uiidil dw ai lcc jig pdsujf C++ js |eff)

    08$ sojff x}al}jo di c `a} dixuwdil ijoe jig gdsxfjtdil saJ$ #dicfuge 6swgda)n9

    diw ojdi.padg${cnj} s[07_;

    x}diw`.-Eiwe} ijoe2 -$;`lews.s& sdrea`.s$& swgdi$;x}diw`.-Neffa& %s *Vi-& s$;}ewu}i 8;

    P^ \a}ks

    0:$ \njw ds j Wjsk1

    J wjsk ds wne jcwdpe efeoeiw a` j P~\a}ks stsweo) Wnet j}e wne aift ambecws wnjw j}e scnegufeg) Dw dsdoxa}wjiw wa sexj}jwe j wjsk `}ao jit cage wnjw dw ojt e~ecuwe gu}dil dws fd`e) Cage ds wawjfft xjssdpe uiwdfe~ecuweg mt j wjsk) Js fail js dw ds |}dwwei ca}}ecwft .d)e) dw `affa|s saoe sdoxfe }ufes }elj}gdil }e/eiw}jict$&j xdece a` cage ojt me e~ecuweg mt oa}e wnji aie wjsk)

    Wjsks cji me wnaulnw a` js }uiidil caicu}}eiwft& wnauln ampdausft |dwn aift j sdilfe CXU wnds ds iepe} w}uftwne cjse) Dw ds j use`uf |jt a` wndikdil jmauw wneo wnauln |nei gesdlidil j stsweo |ne}e wjsks ousw snj}e}esau}ces& a} ousw sticn}aidse wned} jcwdpdwdes) Di mawn sdwujwdais ejcn wjsk ousw ojke use a`sticn}aidsjwdai x}dodwdpes& sucn js seojxna}es a} oessjle zueues& wa eisu}e wnjw wne ape}jff menjpdau} dsca}}ecw d}}esxecwdpe a` wne a}ge} di |ndcn wne wjsks }ejfft ljdi CXU wdoe)

    Caoxj}dil P~\a}ks wa awne} axe}jwdil stsweos& j wjsk cji me wnaulnw a` js j wn}ejg) Wne }ejf gd``e}eicemew|eei P~\a}ks jig wnase awne} axe}jwdil stsweos ds wnjw P~\a}ks njs aift aie x}acess di |ndcn jff wnewn}ejgs .wjsks$ }ui)

    Faakdil jw P~\a}ks JE& wne sjoe jijfal a` wjsk jig wn}ejg nafgs w}ue& muw ia| wne}e ds jfsa ji jijfal a`wne x}acess2 wne x}awecwdai gaojdi) Uifdke& `a} e~joxfe& Uid~ x}acesses wnauln& wne P~\a}ks JE x}awecwdaigaojdi ds iepe} scnegufeg) Dw }eojdis j xjssdpe caiwjdie} `a} wjsks& awne} ambecws jig& a` cau}se& oeoa}t)

    0=$ \njw Gaes Caiwe~w S|dwcndil Eiwjdf1

    Caiwe~w s|dwcndil ds wne oecnjidso mt |ndcn j oufwd/wjskdil axe}jwdil stsweo s|dwcnes caiw}af mew|eei w|awn}ejgs a` e~ecuwdai& wne}emt ldpdil wne dffusdai a` caicu}}eict) A` cau}se& wne scnegufdil jfla}dwno& |ndcnds wne oejis a` gecdgdil |nei wa s|dwcn& jig |ndcn wn}ejg wa s|dwcn wa& |dff njpe j g}jojwdc e``ecw ai na||eff wnjw dffusdai ds ojdiwjdieg) J geskwax axe}jwdil stsweo njs pe}t gd``e}eiw ieegs wa ji ]WAS di wnds

    }elj}g) J ]WAS scnegufdil jfla}dwno& sucn js wne x}da}dwt x}e/eoxwdpe aie useg mt P~\a}ks& ds oa}ecaice}ieg |dwn x}egdcwjmdfdwt .gewe}odidso$ wnji j leie}jf xu}xase AS& |ndcn ds leie}jfft oa}e caice}ieg|dwn jffacjwdil j `jd} snj}e a` }esau}ces wa ejcn use}!x}acess)

    @a} P~\a}ks& caiwe~w s|dwcndil ds sdoxft j ojwwe} a` sjpdil wne cu}}eiw swjwe a` aie wjsk di dws WCM& jigwnei }eswa}dil wne swjwe a` wne ie|ft sefecweg wjsk) Wneswjwe di wnds cjse ds sdoxft wne caiweiw a` wne CXU,s}eldswe}s& dicfugdil wne swjck xadiwe} jig x}al}jo cauiwe}) Wne caiwe~w s|dwcn wdoe ds j `uicwdai a` wneiuome} a` }eldswe}s wnjw ieeg wa me sjpeg jig }eswa}eg) @a} wnds }ejsai& ]DSC x}acessa}s& |ndcn weig wanjpe ojit oa}e }eldswe}s wnji wned} CDSC cauiwe}xj}ws& weig wa njpe faile} caiwe~w s|dwcn wdoes)Jggdwdaijfft& e~w}j }eldswe}s& sucn js `fajwdil xadiw }eldswe}s jfsa jgg wa wnds wdoe) Dw ds `a} wnjw }ejsai wnjw

    =:

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    22/38

    P~\a}ks wjsks cji cnaase |newne} a} iaw wne `fajwdil xadiw }eldswe}s ieeg wa me sjpeg) J wjsk wnjw ojkesia use a` `fajwdil xadiw j}dwnoewdc& gaes iaw ieeg wa sjpe a} }eswa}e wnese }eldswe}s& jig |dff wne}e`a}e njpe j`jswe} caiwe~w s|dwcn wdoe) Wne P^Q@XQWJSK axwdai& xjsseg wa wjskSxj|i.$& caiw}afs |newne} wnese}eldswe}s j}e sjpeg jig }eswa}eg)

    03$ Seojxna}es

    Mjsdcs

    Wne}e j}e wn}ee wtxes a` seojxna}e jpjdfjmfe di wne P~\a}ks |a}fg) Ejcn ds axwdodseg `a} j sxecd`dc`uicwdai) Wnds secwdai faaks jw ejcn a` wne wn}ee wtxes di wu}i& jig e~xfjdis |nei wa use wneo jig |nei iawwa) \ndfe wne}e j}e gd``e}eiw c}ejwe }auwdies `a} ejcn a` wne wn}ee wtxes& wnet jff snj}e wne sjoe diwe}`jce`uicwdais)

    Mdij}t Seojxna}es

    Js wne ijoe doxfdes& mdij}t seojxna}es njpe busw w|a swjwes2`uffa}eoxwt) \nei `uff& j cjff wa seoWjke.$|dff }ewu}i dooegdjweft jig j cjff wa seoLdpe.$ |dff njpe ia e``ecw .iawe2 seoLdpe.$ iepe} mfacks$) \nei wne

    seojxna}e ds eoxwt& j cjff wa seoWjke.$ |dff mfack edwne} uiwdf wne seojxna}e ds ldpei mt jiawne} wjsk& a}wne axwdaijf wdoeauw e~xd}es) Use \JDWQ@A]EPE] `a} wne wdoeauw pjfue wa mfack uiwdf wne seojxna}e dsjpjdfjmfe& jig IAQ\JDW wa }ewu}i dooegdjweft& epei d` wne seojxna}e ds iaw jpjdfjmfe) \nei usdil jwdoeauw& me su}e wa cneck wne swjwus }ewu}i& jig d` dw ds E]]A] cneck wne pjfue a` e}}ia wa eisu}e wnjw wne}ejsai |js j wdoeauw)

    Mdij}t seojxna}es j}e axwdodseg `a} sdlijffdil axe}jwdais mew|eei wjsks& a} `}ao ji DS] wa wjsk fepef) Wnetj}e wne `jswesw a` wne wn}ee seojxna}e& jig j}e `}ezueiwft useg |dwndi P~\a}ks DS]s) \ndfe wnet caufg jfsame useg `a} ouwujf e~cfusdai x}awecwdai& wnds |aufg me sum/axwdojf jig snaufg me jpadgeg) Wne ouwe~seojxna}e wtxe ds gesdlieg `a} eisu}dil ouwujf e~cfusdai jig njs saoe e~w}j `ejwu}es wa x}awecw jljdiswodsuse)

    Cauiwdil Seojxna}es

    Cauiwdil seojxna}es j}e wne faldcjf e~weisdai a` wne mdij}t seojxna}e) Ia|& }jwne} wnji busw w|a swjwes&wne seojxna}e ds j cauiwe}) Js fail js wne cauiw ds l}ejwe} wnji re}a j cjff wa seoWjke.$ |dff }ewu}idooegdjweft .gec}eoeiwdil wne cauiw `d}sw a` cau}se$) Cjffs wa seoLdpe.$ dic}eoeiw wne cauiw) Wne wdoeauws|a}k wne sjoe |jt js di wne mdij}t seojxna}e cjse)

    Use j cauiwdil seojxna}e |nei wne}e j}e j `d~eg iuome} a` }esau}ces wa me jffacjweg& e)l) di j g}dpe} wnjw|jiws wa fdodw wne iuome} a` sdoufwjieaus axeis& a} wa cauiw epeiws& e)l) di j x}aguce}/caisuoe} wtxejxxfdcjwdai |nei wne x}aguce} cji leie}jwe oufwdxfe mfacks a` gjwj wa me caisuoeg)

    Ouwujf E~cfusdai Seojxna}es

    Ouwujf e~cfusdai seojxna}es& a}ouwe~ seojxna}es `a} sna}w& j}e gesdlieg wa x}awecw j c}dwdcjf }eldai a`cage jljdisw sdoufwjieaus e~ecuwdai mt oufwdxfe wjsks) Wnet j}e esseiwdjfft mdij}t seojxna}es di wnjw wnet

    njpe w|a swjwes& fackeg jig uifackeg& muw wnet jfsa njpe saoe jggdwdaijf `ejwu}es gesdlieg wa `u}wne}x}awecw jljdisw mullt cage lewwdil diwa j c}dwdcjf }eldai)

    Wne ket gd``e}eices mew|eei ouwe~ seojxna}es jig mdij}t seojxna}es j}e js `affa|s2

    ]ecu}sdpe

    X}da}dwt dipe}sdai x}awecwdai

    Gefewe sj`ewt

    ==

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    23/38

    07$ Caiwdluaus Oeoa}t JffacjwdaiZue}t 2\nei |e gecfj}e ji j}}jt& |e sjt wnjw dw,s efeoeiws j}e caiwdluaus) \njw oeoa}t ga |e }e`e} wa ne}e1 WnePd}wujf a} Xntsdcjf11

    Wne ojdi x}amfeo ds wnjw d |jiw saoe gjwj wa me caiwdluaus di w}ue seise di xntsdcjf oeoa}t11 Na| cji djcndepe wnjw1

    J$ Ampdausft ji j}}jt ousw me di caiwdluaus pd}wujf oeoa}t)

    Di j PO AS wne j}}jt |dff iaw iecessj}dft me xntsdcjfft caiwdluaus)

    Di j iai/PO AS wne j}}jt |dff ampdausft me di caiwdluaus xntsdcjf oeoa}t)

    05$ \nt ``fusn.swgdi$ ds |}ail

    Ai accjsdais tau ojt ieeg wa cfej} ui|jiweg gjwj di ji dixuw sw}ejo& oasw caooaift ketmaj}g dixuw)Aie `}ezueiwft sullesweg |jt a` gadil wnds ds mt usdil ``fusn.swgdi$) Wnds ds dica}}ecw& jig snaufg mejpadgeg& ne}e ds |nt)

    swgdi ds j swjigj}g @DFE" pj}djmfe wnjw xadiws wa wne dixuw sw}ejo ia}ojfft useg `a} ketmaj}g dixuw) Wne``fusn.$ `uicwdai ds geeoeg wa `fusn mu``e}s) Xuw wne w|a walewne} jig tau njpe j oewnag `a} cfej}dil wnedixuw sw}ejo ejsdft& }dlnw1 \]AIL* Wnds ds j caooai odscaicexwdai di C jig C++ x}al}joodil& ji e~w}jcw`}ao wne C swjigj}g |dff nefx e~xfjdi2

    diw ``fusn.@DFE "asw}ejo$;

    asw}ejo xadiws wa ji auwxuw sw}ejo a} ji uxgjwe sw}ejo di |ndcn wneoasw }eceiw axe}jwdai |js iaw dixuw& wne ``fusn `uicwdai cjuses jitui|}dwwei gjwj `a} wnjw sw}ejo wa me gefdpe}eg wa wne nasw eipd}aioeiw wame |}dwwei wa wne `dfe; awne}|dse wne menjpda} ds uige`dieg)

    Sa& d` wne `dfe sw}ejo ds `a} dixuw use& js swgdi ds& wne menjpdau} ds uige`dieg& wne}e`a}e dw ds iaw jccexwjmfe wause ``fusn.$ `a} cfej}dil ketmaj}g dixuw)

    00$ Oe}le sa}w

    Di caoxuwe} scdeice& oe}le sa}w a}oe}lesa}w ds j A.i fal i$ sa}wdil jfla}dwno) Dw ds ejst wa doxfeoeiwoe}le sa}w sucn wnjw dw ds swjmfe& oejidil dw x}ese}pes wne dixuw a}ge} a` ezujf efeoeiws di wne sa}weg auwxuw)Dw ds ji e~joxfe a` wne gdpdge jig caizue}jfla}dwnodc xj}jgdlo) Dw ds j caoxj}dsai sa}w) Wne jfla}dwno |jsdipeiweg mt Bani pai Ieuojii di :475)

    Caicexwujfft& oe}le sa}w |a}ks js `affa|s2

    Gdpdge wne uisa}weg fdsw diwa w|a sumfdsws a` jmauw njf` wne sdre

    Sa}w ejcn a` wne w|a sumfdsws }ecu}sdpeft uiwdf |e njpe fdsw sdres a` feilwn :& di |ndcn cjse wne fdsw dwsef` ds}ewu}ieg

    Oe}le wne w|a sa}weg sumfdsws mjck diwa aie sa}weg fdsw)

    Oe}lesa}w dica}xa}jwes w|a ojdi dgejs wa dox}ape dws }uiwdoe2

    J sojff fdsw |dff wjke `e|e} swexs wa sa}w wnji j fj}le fdsw)

    =3

    http://en.wikipedia.org/wiki/Computer_sciencehttp://en.wikipedia.org/wiki/Big_O_notationhttp://en.wikipedia.org/wiki/Sorting_algorithmhttp://en.wikipedia.org/wiki/Divide_and_conquer_algorithmhttp://en.wikipedia.org/wiki/Comparison_sorthttp://en.wikipedia.org/wiki/John_von_Neumannhttp://en.wikipedia.org/wiki/1945http://en.wikipedia.org/wiki/Recursionhttp://en.wikipedia.org/wiki/Merge_algorithmhttp://en.wikipedia.org/wiki/Computer_sciencehttp://en.wikipedia.org/wiki/Big_O_notationhttp://en.wikipedia.org/wiki/Sorting_algorithmhttp://en.wikipedia.org/wiki/Divide_and_conquer_algorithmhttp://en.wikipedia.org/wiki/Comparison_sorthttp://en.wikipedia.org/wiki/John_von_Neumannhttp://en.wikipedia.org/wiki/1945http://en.wikipedia.org/wiki/Recursionhttp://en.wikipedia.org/wiki/Merge_algorithm
  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    24/38

    @e|e} swexs j}e }ezud}eg wa caisw}ucw j sa}weg fdsw `}ao w|a sa}weg fdsws wnji w|a uisa}weg fdsws) @a} e~joxfe&tau aift njpe wa w}jpe}se ejcn fdsw aice d` wnet,}e jf}ejgt sa}weg .see wneoe}le `uicwdai mefa| `a} jie~joxfe doxfeoeiwjwdai

    Di sa}wdil i dweos& oe}le sa}w njs ji jpe}jle jig |a}sw/cjse xe}`a}ojice a`A.i fal i$) D` wne }uiidil wdoea` oe}le sa}w `a} j fdsw a` feilwn i ds W.i$& wnei wne }ecu}}eice W.i$ ? =W.i!=$ + i `affa|s `}ao wne ge`didwdai a`wne jfla}dwno .jxxft wne jfla}dwno wa w|a fdsws a` njf` wne sdre a` wne a}dldijf fdsw& jig jgg wnei swexs wjkei wa

    oe}le wne }esufwdil w|a fdsws$) Wne cfaseg `a}o `affa|s `}ao wneojswe} wnea}eo)

    00$ EA@ ds ji diwele} ge`dieg di 6swgda)n9

    sa |nw ds wne diwel}jf pjfue a` EA@1

    J$ Na| j}e tau sdlijffdil eig a` `dfe wa wa tau} x}al}jo 1 E)l) uige} Fdiu~!Uid~!Ojc AS ^ ewc dw |aufg mecaiw}af/G) D wndik uige} GAS!\diga|s!ewc dw,s x}amjmft saoewndil iai/swjigj}g fdke caiw}af/R .1$)

    J$ Wnjw,s aift j we}odijf/sxecd`dc wndil wnjw njs iawndil wa ga |dwn wne dixuw x}al}jos j}e lewwdil*Uige} Fdiu~!Uid~!Ojc AS ^& D,o x}ewwt su}e dw we}odijf D!A cji me pe}t oucn caiw}affeg |dwn swwt)@}ao j x}al}jo xadiw a` pde|& dixuw `}ao j `dfe& `d`a& sackew& xdxe a} we}odijf& caoes js j }j| sw}ejo a`cnj}s& jig }ejg.$ `jdfs |nei wne eig ds }ejcneg)Iawe wnjw tau cji pe}t |eff seig ji EAW .JSCDD cnj}jcwe} 87$ cnj}jcwe} js dixuw wa j x}al}jo |dwn CW]F+PCW]F+G a} |njwepe} we}odijf/sxecd`dc ket sw}ake sezueice)

    Wne EA@ ojc}a e~xjigs wa ji doxfeoeiwjwdai/gexeigeiw caiswjiw e~x}essdai |nase pjfue ds j ieljwdpediw)Wnds pjfus ds a`wei /:& muw dw ojt me /=& /:05 a} jit awne} ieljwdpe pjfue)

    J$ \nei tau eiwe} /:& dw xuws w|a cnj}jcwe}s di wne sw}ejo 2 ,/, jig ,:, |nase JSCDD .D gai,w kia| `a}EMCGDC$ pjfues j}e 75 .gecdojf$ jig 74 .gecdojf$ }esxecwdpeft)Wnei& |nei wnese cnj}jcwe}s j}e }ejg& c ds sew wa wnese diwele} pjfues)

    Wtxdcjfft cnj} pjfues j}e di }jile [/:=>&:=&+:=

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    25/38

    `a} j safuwdai wnjw ds mewwe}wnji wne afg aie) Di we}os a`cage leie}jwdai& mewwe} oejis cage wnjw e~ecuwes`jswe}& jfwnauln wne}e j}e cjses |ne}e cage wnjw accuxdes fess sxjce ds oa}e pjfujmfe .e)l) eomeggegxfjw`a}os |dwn fdodweg oeoa}t jpjdfjmfe$)

    Axwdodrjwdai accu}s jw w|a fepefs) Wne x}al}jooe}cji ojiujfft axwdodre j x}al}jo a} j caoxdfe}x}al}jocji juwaojwdcjfft axwdodre dw) Js Kiuwn& Ke}idlnji& jig Xdke sullesw jmape& wnauln& ojiujf axwdodrjwdai dsmesw fe`w uiwdf j xe}`a}ojice x}amfeo accu}s; j`we} jff wne}e ds ia seise di sxeigdil gjts ojkdil tau}

    x}al}jo }ui secaigs `jswe} d` iamagt ds |jdwdil `a} dw) Ojkdil wne cage la `jswe} jfsa njs j weigeict waojke dw oa}e caoxfdcjweg& waa& sax}eojwu}e axwdodrjwdai ds fdkeft wa fejpe tau |dwn oa}e mullt jig fessojdiwjdijmfe cage)

    04$ sezueice xadiw

    Di wne C fjilujle& j sezueice xadiw ds j xfjce di cage busw j`we} wne we}odijwdai a` ji e~x}essdai& me`a}e jita` wne vv& & 12& a}& axe}jwa}s& a} busw me`a}e j `uicwdai cjff& j`we} jff a` dws j}luoeiws njpe meei epjfujweg)

    Jw j sezueice xadiw& jff pj}djmfe uxgjwes jigsdge/e``ecws sdice wne x}epdaus sezueice xadiw j}e luj}jiweegwa njpe wjkei xfjce)

    @}ao wne DSA Swjigj}g2

    Mew|eei wne x}epdaus jig ie~w sezueice xadiw ji ambecw snjff njpe dws swa}eg pjfue oagd`deg jw oasw aicemt wne epjfujwdai a` ji e~x}essdai) @u}wne}oa}e& wne x}da} pjfue snjff me jccesseg aift wa gewe}odie wnepjfue wa me swa}eg)

    Wne `d}sw seiweice ds x}ewwt ampdaus2 tau,}e iaw jffa|eg wa oagd`t j pj}djmfe w|dce mew|eei sezueice xadiws).Sa j swjweoeiw fdke d ? 5 " d++; ds iaw jffa|eg& mecjuse d ds mawn medil jssdlieg wa& jig uxgjweg js j sdgee``ecw a` wne ++)$

    Wne secaig seiweice ds sfdlnwft fess ampdaus& jig mesw e~xfjdieg |dwn ji e~joxfe) Wne menjpda} a` wndscage2 j[d_ ? d++; ds uige`dieg) \nt1 mecjuse wne ,x}da} pjfue, a` d ds medil jccesseg wa gewe}odie |ne}e dij[_& diswejg a` busw wa caoxuwe wne pjfue a` d++)

    /==$ ))) \eff& jcwujfft tau cji iaw& di `jcw& ga wnjw) A} tau cji& dw,s busw iaw :88%luj}jiweeg wa |a}k jcca}gdil wa wne DSA C swjigj}g) Wa use wne ~a} s|jx ca}}ecwft& tau ieeg saoewndiloa}e fdke wnds2

    jY?m; mY?j; jY?m;

    \nt1 \eff& di DSA C& j pj}djmfe ds iaw jffa|eg wa me oagd`deg oa}e wnji aice mew|eeisezueice xadiws)Sdice j ds oagd`deg w|dce di wne a}dldijf e~x}essdai& wne e~x}essdai ds uige`dieg& jig wnus odlnw iaw |a}k aijff caoxdfe}s)

    @d}sw a``& d` dw |js wa me xj}eiwnesdreg& dw |aufg la2

    j Y? .m Y? .j Y? m$$;3 = :

    =5

    http://www.everything2.com/index.pl?node=betterhttp://www.everything2.com/index.pl?node=code%20generationhttp://www.everything2.com/index.pl?node=executes%20fasterhttp://www.everything2.com/index.pl?node=executes%20fasterhttp://www.everything2.com/index.pl?node=occupies%20less%20spacehttp://www.everything2.com/index.pl?node=embedded%20platformhttp://www.everything2.com/index.pl?node=embedded%20platformhttp://www.everything2.com/index.pl?node=programmerhttp://www.everything2.com/index.pl?node=compilerhttp://www.everything2.com/index.pl?node=performance%20problemhttp://www.everything2.com/index.pl?node=premature%20optimizationhttp://www.everything2.com/index.pl?node=more%20buggyhttp://www.everything2.com/index.pl?node=less%20maintainablehttp://www.everything2.com/index.pl?node=less%20maintainablehttp://www.everything2.com/index.pl?node=Chttp://www.everything2.com/index.pl?node=source%20codehttp://www.everything2.com/index.pl?node=expressionhttp://www.everything2.com/index.pl?node=%26%23124%3B%26%23124%3Bhttp://www.everything2.com/index.pl?node=%26%26http://www.everything2.com/index.pl?node=%3F%3Ahttp://www.everything2.com/index.pl?node=%2Chttp://www.everything2.com/index.pl?node=side-effectshttp://www.everything2.com/index.pl?node=ISOhttp://www.everything2.com/index.pl?node=%2B%2Bhttp://www.everything2.com/index.pl?node=swaphttp://www.everything2.com/index.pl?node=variablehttp://www.everything2.com/index.pl?node=temporary%20variablehttp://www.everything2.com/index.pl?node=simplehttp://www.everything2.com/index.pl?node=any%20sufficiently%20advanced%20technology%20is%20indistinguishable%20from%20magichttp://www.everything2.com/index.pl?node=XORhttp://www.everything2.com/index.pl?node=operatorhttp://www.everything2.com/index.pl?node=Chttp://www.everything2.com/index.pl?node=C%2B%2Bhttp://www.everything2.com/index.pl?node=ISOhttp://www.everything2.com/index.pl?node=sequence%20pointhttp://www.everything2.com/index.pl?node=compilerhttp://www.everything2.com/index.pl?node=betterhttp://www.everything2.com/index.pl?node=code%20generationhttp://www.everything2.com/index.pl?node=executes%20fasterhttp://www.everything2.com/index.pl?node=executes%20fasterhttp://www.everything2.com/index.pl?node=occupies%20less%20spacehttp://www.everything2.com/index.pl?node=embedded%20platformhttp://www.everything2.com/index.pl?node=embedded%20platformhttp://www.everything2.com/index.pl?node=programmerhttp://www.everything2.com/index.pl?node=compilerhttp://www.everything2.com/index.pl?node=performance%20problemhttp://www.everything2.com/index.pl?node=premature%20optimizationhttp://www.everything2.com/index.pl?node=more%20buggyhttp://www.everything2.com/index.pl?node=less%20maintainablehttp://www.everything2.com/index.pl?node=less%20maintainablehttp://www.everything2.com/index.pl?node=Chttp://www.everything2.com/index.pl?node=source%20codehttp://www.everything2.com/index.pl?node=expressionhttp://www.everything2.com/index.pl?node=%26%23124%3B%26%23124%3Bhttp://www.everything2.com/index.pl?node=%26%26http://www.everything2.com/index.pl?node=%3F%3Ahttp://www.everything2.com/index.pl?node=%2Chttp://www.everything2.com/index.pl?node=side-effectshttp://www.everything2.com/index.pl?node=ISOhttp://www.everything2.com/index.pl?node=%2B%2Bhttp://www.everything2.com/index.pl?node=swaphttp://www.everything2.com/index.pl?node=variablehttp://www.everything2.com/index.pl?node=temporary%20variablehttp://www.everything2.com/index.pl?node=simplehttp://www.everything2.com/index.pl?node=any%20sufficiently%20advanced%20technology%20is%20indistinguishable%20from%20magichttp://www.everything2.com/index.pl?node=XORhttp://www.everything2.com/index.pl?node=operatorhttp://www.everything2.com/index.pl?node=Chttp://www.everything2.com/index.pl?node=C%2B%2Bhttp://www.everything2.com/index.pl?node=ISOhttp://www.everything2.com/index.pl?node=sequence%20pointhttp://www.everything2.com/index.pl?node=compiler
  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    26/38

    Wnds busw nefxs pdsujfdre wne a}ge} wnjw wndils njxxei di)

    Fews wjke

    j ? :88: :8::m ? ::88 8::8

    Wne `d}sw ^A] oagd`des j2j ? :88: :8::m ? ::88 8::8j, ? 8:8: ::8:

    Wne secaig ^A] wnei wjkes j, jig m& swa}dil wne }esufw diwa m,2

    m ? ::88 8::8j, ? 8:8: ::8:m, ? :88: :8::

    Iawe wnjw m, ia| ds wne sjoe pjfue js wne a}dldijf j) Wne fjsw ^A] wnei axe}jwes ai j, jig m,& swa}dil diwa j-2

    j, ? 8:8: ::8:m, ? :88: :8::j- ? ::88 8::8

    Wne `dijf }esufws swa}eg .j- jig m,$ j}e wne sjoe js wne a}dldijf j jig m& e~cexw s|jxxeg)

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    27/38

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    28/38

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    29/38

    Jit .caisafe a} LUD$ jxxfdcjwdai njpdil j \diOjdi& muw ia ojdi& `uicwdai& ds pjfdg |dwn OdiL\ 3)7)5)Dw caoxdfes jig }ui `die)

    Wne}e j}e jfsa j faw a` caoxdfe}s wnjw few tau |}dwe j swj}wux jsseomft oagufe))) Tau cji cnjile wnds swj}wuxoagufe di a}ge} wa cjff jiawne} `uicwdai& sucn js IawOjdi.$)

    @dijfft& fdike}s ojt x}apdge j oeji wa cnjile wne eiw}t xadiw))) ]exfjcdil Qswj}w& SWJ]W a} |njwepe} eiw}t

    xadiw useg mt ge`jufw& mt wne swj}wux cage a` wne }uiwdoe fdm}j}t& |dwn j use} x}apdgeg eiw}t xadiw) X}apdgdil j`uicwdai ijoe& ojt a} ojt iaw |a}k& gexeigdil ai wne caoxdfe}& jig |newne} saoe iecessj}t swj}wux cagenjs wa me e~ecuweg me`a}e jit use} ge`dieg `uicwdai)

    Ji diwe}eswdil wndil& |ndcn ojt |a}k |dwn saoe caoxdfe}s& ds wa sew wne eiw}t xadiw& wn}auln j fdike} axwdai&wa Qjma}w a} E~dwX}acess))) Wnjw ojt me `uiit) 2$

    8$ Weff oe na|1111Weff oe g a!x ig |nt ds wnjw sa1111

    ojdi.${diw d?:8;d`./: 6 sdrea`.++d$$x}diw`.-\dx}a- $;efsex}diw`.-Sjskei- $;

    J$ Sdrea` ds wne caoxdfe wdoe uij}t axe}jwa}) Sa dw,ff iaw epjfujwe wne Qe~x}essdai) Sa ++d |dff iaw meepjfujweg) Sa wne pjfue a` d ds :8)Ie~w& Sdrea` axe}jwa} tedfgs uisdlieg diwele} pjfue) Tau j}e caoxj}dil sdlieg pjfue jig uisdlieg pjfue).de$ /:.Sdlieg pjfue$ jig 7.uisdlieg pjfue$

    D` tau j}e caoxj}dil sdlieg diw pjfue jig uisdlieg diw pjfue wnei sdlieg pjfue |dff me caipe}weg wa uisdliegpjfue).]e`e} K ] =& xjle ia2 77 xjle ia2 :4> .J}dwnojwdc Caipe}sdais$ $Sa d` tau j}e wjkdil /: js j uisdlieg pjfue wnei dw,ff mecaoe j mdllesw xasdwdpe ia)Sa wne caigdwdai `jdfs& jig dw,ff x}diw sjskei)

    >:$ \njw ds wne gd``e}eice mew|eei wne gecfj}jwdai jig wne ge`didwdai a` j pj}djmfe1

    Wne ge`didwdai ds wne aie wnjw jcwujfft jffacjwes sxjce& jig x}apdges ji didwdjfdrjwdai pjfue& d` jit)

    Wne}e cji me ojit gecfj}jwdais& muw wne}e ousw me e~jcwft aie ge`didwdai) J ge`didwdai weffs wne caoxdfe} wasew jsdge swa}jle `a} wne pj}djmfe) J gecfj}jwdai ojkes wne pj}djmfe kia|i wa xj}ws a` wne x}al}jo wnjw ojt|dsn wa use dw) J pj}djmfe odlnw me ge`dieg jig gecfj}eg di wne sjoe swjweoeiw)

    >=$ \njws sna}w/cd}cudwdil di C e~x}essdais1

    \njw wnds oejis ds wnjw wne }dlnw njig sdge a` wne e~x}essdai ds iaw epjfujweg d` wne fe`w njig sdge gewe}odieswne auwcaoe) Wnjw ds d` wne fe`w njig sdge ds w}ue `a} vv a} `jfse `a} & wne }dlnw njig sdge ds iaw epjfujweg)

    >3$ \njws |}ail |dwn wne e~x}essdai j[d_?d++; 1 \njws j sezueice xadiw1

    Jfwnauln dws su}x}dsdil wnjw ji e~x}essdai fdke d?d+:; ds caoxfeweft pjfdg& saoewndil fdke j[d_?d++; ds iaw) Wndsds mecjuse jff jccesses wa ji efeoeiw ousw me wa cnjile wne pjfue a` wnjw pj}djmfe) Di wne swjweoeiw j[d_?d+

    =4

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    30/38

    +; & wne jccess wa d ds iaw `a} dwsef`& muw `a} j[d_ jig sa dws dipjfdg) Ai sdodfj} fdies& d?d++; a} d?++d; j}e dipjfdg) D`tau |jiw wa dic}eoeiw wne pjfue a` d& use d?d+:; a} d+?:; a} d++; a} ++d; jig iaw saoe caomdijwdai)

    J sezueice xadiw ds j swjwe di wdoe .busw j`we} wne epjfujwdai a` j `uff e~x}essdai& a} jw wne vv& & 12& a}caooj axe}jwa}s& a} busw me`a}e j cjff wa j `uicwdai$ jw |ndcn wne}e j}e ia sdge e``ecws)

    Wne JISD!DSA C Swjigj}g swjwes wnjw

    Mew|eei wne x}epdaus jig ie~w sezueice xadiw ji ambecw snjff njpe dws swa}egpjfue oagd`deg jw oasw aice mt wne epjfujwdai a` ji e~x}essdai) @u}wne}oa}e&wne x}da} pjfue snjff me jccesseg aift wa gewe}odie wne pjfue wa me swa}eg)

    Jw ejcn sezueice xadiw& wne sdge e``ecws a` jff x}epdaus e~x}essdais |dff me caoxfeweg) Wnds ds |nt taucjiiaw }eft ai e~x}essdais sucn js j[d_ ? d++;& mecjuse wne}e ds ia sezueice xadiw sxecd`deg `a} wnejssdlioeiw& dic}eoeiw a} dige~ axe}jwa}s& tau gai,w kia| |nei wne e``ecw a` wne dic}eoeiw ai d accu}s)

    Wne sezueice xadiws fjdg ga|i di wne Swjigj}g j}e wne `affa|dil2

    " Wne xadiw a` cjffdil j `uicwdai& j`we} epjfujwdil dws j}luoeiws)

    " Wne eig a` wne `d}sw axe}jig a` wne axe}jwa})" Wne eig a` wne `d}sw axe}jig a` wne vv axe}jwa})" Wne eig a` wne `d}sw axe}jig a` wne 12 caigdwdaijf axe}jwa})" Wne eig a` wne ejcn axe}jig a` wne caooj axe}jwa})" Caoxfewdil wne epjfujwdai a` j `uff e~x}essdai) Wnet j}e wne `affa|dil2

    a Epjfujwdil wne didwdjfdre} a` ji juwa ambecw)a Wne e~x}essdai di ji 1a}gdij}t1 swjweoeiw1ji e~x}essdai `affa|eg mt seodcafai)a Wne caiw}affdil e~x}essdais di ga& |ndfe& d`& s|dwcn a} `a} swjweoeiws)a Wne awne} w|a e~x}essdais di j `a} swjweoeiw)a Wne e~x}essdai di j }ewu}i swjweoeiw)

    >7$ Ds 5[j}}jt_ wne sjoe js j}}jt[5_1

    Tes*

    Sdice j}}jt sumsc}dxwdil ds caoouwjwdpe di C) Wnjw ds

    j}}jt[i_ ?? "..j}}jt$+.i$$ ?? "..i$+.j}}jt$$ ?? i[j}}jt_

    >5$ Ds oeoa}t jffacjweg |nei j pj} ds gecfj}eg1

    J$ Ia oeoa}t ds iaw jffacjweg |nei j pj}djmfe ds gecfj}eg) Oeoa}t ds jffacjweg aift |nei j pj}djmfe dsge`dieg)

    diw j?8; !!ge`didwdai) oeo jffacjweg)

    diw m; !!ge`diwdai) oeo jffacjweg

    diw c.5$; !!ge`didwdai) oeo jffacjweg

    e~we}i diw g; !!gecfj}jwdai) ia oeo jffacjweg

    J$ Swa}jle `a} pj}djmfes ds jffacjweg jw saoe xfjce me`a}e ` d}sw use a` wne pj}djmfe)Dw ojt me j`we} gecfj}jwdai& jig me`a}e `d}sw use)Dw ojt me jw wne swj}w a` wne eicfasdil caoxauig/swjweoeiw)Dw ojt me jw wne swj}w a` wne `uicwdai)Dw ojt me jw swj}wux wdoe .epei `a} juwaojwdc jig }eldswe} pj}djmfes$)Dw ojt me me`a}e tau,pe gesdlieg tau} x}al}jo* Tes& dw,s xntsdcjfft xassdmfe*

    38

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    31/38

    >0$ \njw ds j caisw xadiwe}1

    Jis|e}2Wne jccess oagd`de} ket|a}g caisw ds j x}aodse wne x}al}jooe} ojkes wa wne caoxdfe} wnjw wne pjfue a` jpj}djmfe |dff iaw me cnjileg j`we} dw ds didwdjfdreg) Wne caoxdfe} |dff ei`a}ce wnjw x}aodse js mesw dw cji mt iaweijmfdil wne x}al}jooe} wa |}dwe cage |ndcn oagd`des j pj}djmfe wnjw njs meei gecfj}eg caisw) J caiswxadiwe}& a} oa}e ca}}ecwft& j xadiwe} wa caisw& ds j xadiwe} |ndcn xadiws wa gjwj wnjw ds caisw .caiswjiw& a}

    uicnjildil$) J xadiwe} wa caisw ds gecfj}eg mt xuwwdil wne |a}g caisw jw wne meldiidil a` wne xadiwe}gecfj}jwdai) Wnds gecfj}es j xadiwe} |ndcn xadiws wa gjwj wnjw cjiw me oagd`deg) Wne xadiwe} dwsef` cji meoagd`deg) Wne `affa|dil e~joxfe dffusw}jwes saoe feljf jig dffeljf uses a` j caisw xadiwe}2

    caisw cnj} "sw} ? neffa;cnj} c ? "sw} !" feljf "!sw}++; !" feljf "!"sw} ? j; !" dffeljf "!sw}[:_ ? m; !" dffeljf "!

    Wne `d}sw w|a swjweoeiws ne}e j}e feljf mecjuse wnet ga iaw oagd`t wne gjwj wnjw sw} xadiws wa) Wne ie~w w|aswjweoeiws j}e dffeljf mecjuse wnet oagd`t wne gjwj xadiweg wa mt sw})

    Xadiwe}s wa caisw j}e oasw a`wei useg di gecfj}dil `uicwdai xj}joewe}s) @a} diswjice& j `uicwdai wnjw cauiwegwne iuome} a` cnj}jcwe}s di j sw}dil |aufg iaw ieeg wa cnjile wne caiweiws a` wne sw}dil& jig dw odlnw me

    |}dwwei wnds |jt2

    otQsw}fei.caisw cnj} "sw}${))))diw cauiw ? 8;))))|ndfe ."sw}++$)))){)))))))))cauiw++;))))))))}ewu}i cauiw;

    Iawe wnjw iai/caisw xadiwe}s j}e doxfdcdwft caipe}weg wa caisw xadiwe}s |nei ieegeg& muw caisw xadiwe}s j}eiaw caipe}weg wa iai/caisw xadiwe}s) Wnds oejis wnjw otQsw}fei.$ caufg me cjffeg |dwn edwne} j caisw a} jiai/caisw cnj}jcwe} xadiwe})

    >>$ dixfdcdw diw

    J$ Edwne} tau,}e x}al}joodil di oage}i C2 C44)Di wnjw cjse& doxfdcdw diw njs meei mjiieg .jig jit x}al}jo usdil doxfdcdw diw `ejwu}e ds dff/`a}oeg& jgdjliaswdc oessjle ds }ezud}eg& jig menjpda} ds uige`dieg d` wne caoxdfe} auwxuws j x}al}jo$)Muw& di C44& tau gai,w njpe wa }ewu}i e~xfdcdwft jit pjfue `}ao ojdi.$& 8 ds }ewu}ieg)

    @}ao i::=7 .? C44 + WC: + WC=$

    3:

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    32/38

    D` wne }ewu}i wtxe a` wne ojdi `uicwdai ds j wtxe caoxjwdmfe |dwn diw& j }ewu}i `}ao wnedidwdjf cjff wa wne ojdi `uicwdai ds ezudpjfeiw wa cjffdil wne e~dw `uicwdai |dwn wne pjfue}ewu}ieg mt wne ojdi `uicwdai js dws j}luoeiw;:8$ }ejcndil wne wnjw we}odijwes wneojdi `uicwdai }ewu}is j pjfue a` 8) D` wne }ewu}i wtxe ds iaw caoxjwdmfe |dwn diw& wnewe}odijwdai swjwus }ewu}ieg wa wne nasw eipd}aioeiw ds uisxecd`deg)

    D` tau,}e usdil wne afg& muw |dgeft useg& C48& wnei& doxfdcdw diw ds xe}odwweg)

    Jit C x}al}jo `a} |ndcn wne swjigj}g DSA!DEC 4>442:444 sjts wnjw dw njs uige`dieg menjpda}& njsuige`dieg menjpda})

    Uige`dieg menjpda} oejis iawndil oa}e wnji -wne swjigj}g gaesi,w doxase jitwndil ai wne menjpda} a` wndsx}al}jo-)

    D` wne caoxdfe} gaesi,w gacuoeiw jit sxecd`dc menjpda}& wnei& wne caoxdfe} ds `}ee wa ga jitwndil dw |jiws|nei wnds x}al}jo ds e~ecuweg& jig tew cfjdo wa me cai`a}odil wa wne C swjigj}g)

    D` wne caoxdfe} gaes gacuoeiw .tau cji,w cfjdo wnjw dw gaes gacuoeiw saoewndil |dwnauw njpdil ]W@O$ jsxecd`dc menjpda}& wnei& tau cji }eft ai dw& muw tau} x}al}jo |dff iaw me xa}wjmfe wa awne} caoxdfe}s)

    >4$ gd`` m!| uidai i sw}ucwu}e

    J$ Di uidais& wne}e,s aift aie `defg swa}eg jw j w doe)Di sw}ucwu}es& jff `defgs cji me swa}eg jw wne sjoe wdoe)Di awne} |a}gs& j sw}ucwu}e ds j }eca}g& caiwjdidil sepe}jf pjfues& |ndfe uidais cji aift swa}e j sdilfe pjfue)

    @a} e~joxfe2sw}ucw {diw ~; `fajw t; s;s)~?7=;s)t?78)5;x}diw`.-%g %l-& s)~& s)t$; !" snaufg gdsxfjt 7= 78)5 "!

    uidai {diw ~; `fajw t; s;

    s)~?7=; !" ak& muw ia|& tau ouswi,w }ejg s)t "!

    s)t?78)5; !" ak& muw ia|& tau ouswi,w }ejg s)~) s)~ ds ge`didwdpeft fasw "!x}diw`.-%l-& s)t$; !" snaufg gdsxfjt 78)5 "!

    48$ C44Iawe2 C44 ds jfsa wne ijoe a` j C caoxdfe} `a} wne We~js Disw}uoeiws WD/44!7J naoe caoxuwe}) Jsdge `}aomedil j C caoxdfe}& dw ds awne}|dse ui}efjweg)

    J`we} wne JISD swjigj}gdrjwdai x}acess& wne C fjilujle sxecd`dcjwdai }eojdieg }efjwdpeft swjwdc `a} saoewdoe& |ne}ejs C++ caiwdiueg wa epafpe& fj}left gu}dil dws a|i swjigj}gdrjwdai e``a}w) Ia}ojwdpe Joeigoeiw: c}ejweg j ie| swjigj}g `a} wne C fjilujle di :445& muw aift wa ca}}ecw saoe gewjdfs a` wne C>4 swjigj}gjig wa jgg oa}e e~weisdpe suxxa}w `a} diwe}ijwdaijf cnj}jcwe} sews) Na|epe}& wne swjigj}g uige}|eiw `u}wne}}epdsdai di wne fjwe :448s& fejgdil wa wne xumfdcjwdai a` DSA 4>442:444 di :444) Wnds swjigj}g ds caooaift}e`e}}eg wa js -C44)- Dw |js jgaxweg js ji JISD swjigj}g di Oj}cn =888)

    C44 diw}aguceg sepe}jf ie| `ejwu}es& ojit a` |ndcn njg jf}ejgt meei doxfeoeiweg js e~weisdais disepe}jf caoxdfe}s2Difdie `uicwdaisPj}djmfes cji me gecfj}eg jit|ne}e .js di C++$& }jwne} wnji aift j`we} jiawne} gecfj}jwdai a} wne swj}w a` jcaoxauig swjweoeiwSepe}jf ie| gjwj wtxes& dicfugdil fail fail diw& axwdaijf e~weigeg diwele} wtxes& ji e~xfdcdw maafeji gjwjwtxe& jig j caoxfe~ wtxe wa }ex}eseiw caoxfe~ iuome}sPj}djmfe/feilwn j}}jtsSuxxa}w `a} aie/fdie caooeiws meldiidil |dwn !!& js di MCXF a} C++Ie| fdm}j}t `uicwdais& sucn js six}diw`Ie| nejge} `dfes& sucn js swgmaaf)n jig diwwtxes)n

    3=

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    33/38

    Wtxe/leie}dc ojwn `uicwdais .wlojwn)n$Dox}apeg suxxa}w `a} DEEE `fajwdil xadiwGesdlijweg didwdjfdre}sCaoxauig fdwe}jfsSuxxa}w `a} pj}djgdc ojc}as .ojc}as a` pj}djmfe j}dwt$}esw}dcw zujfd`dcjwdai wa jffa| oa}e jll}essdpe cage axwdodrjwdai

    C44 ds `a} wne oasw xj}w ux|j}g/caoxjwdmfe |dwn C48& muw ds sw}dcwe} di saoe |jts; di xj}wdcufj}& j gecfj}jwdaiwnjw fjcks j wtxe sxecd`de} ia faile} njs diw doxfdcdwft jssuoeg) Wne C swjigj}gs caoodwwee gecdgeg wnjw dw|js a` oa}e pjfue `a} caoxdfe}s wa gdjliase dijgpe}weiw aodssdai a` wne wtxe sxecd`de} wnji wa sdfeiwftx}acess feljct cage wnjw }efdeg ai doxfdcdw diw) Di x}jcwdce& caoxdfe}s j}e fdkeft wa gdjliase wne aodssdai muwjfsa jssuoe diw jig caiwdiue w}jisfjwdil wne x}al}jo)

    LCC jig awne} C caoxdfe}s ia| suxxa}w ojit a` wne ie| `ejwu}es a` C44) Na|epe}& wne}e njs meei fesssuxxa}w `}ao peiga}s sucn js Odc}asa`w jig Ma}fjig wnjw njpe ojdift `acuseg ai C++& sdice C++ x}apdgessdodfj} `uicwdaijfdwt dox}apeoeiw)

    LCC& gesxdwe dws e~weisdpe C44 suxxa}w& ds swdff iaw j caoxfeweft caoxfdjiw doxfeoeiwjwdai; sepe}jf ket`ejwu}es j}e odssdil a} gai,w |a}k ca}}ecwft)

    4:$ Usjle

    C,s x}doj}t use ds `a} -stsweo x}al}joodil-& dicfugdil doxfeoeiwdil axe}jwdil stsweos jig eomeggegstsweo jxxfdcjwdais& gue wa j caomdijwdai a` gesd}jmfe cnj}jcwe}dswdcs sucn js cage xa}wjmdfdwt jige``dcdeict& jmdfdwt wa jccess sxecd`dc nj}g|j}e jgg}esses& jmdfdwt wa -xui- wtxes wa ojwcn e~we}ijfft doxaseggjwj jccess }ezud}eoeiws& jig fa| }uiwdoe geojig ai stsweo }esau}ces)

    C njs jfsa meei |dgeft useg wa doxfeoeiw eig/use} jxxfdcjwdais& jfwnauln js jxxfdcjwdais mecjoe fj}le}oucn a` wnjw gepefaxoeiw snd`weg wa awne}& ndlne}/fepef fjilujles)

    Aie caisezueice a` C,s |dge jccexwjice jig e``dcdeict ds wnjw wne caoxdfe}s& fdm}j}des& jig diwe}x}ewe}s a`awne} ndlne}/fepef fjilujles j}e a`wei doxfeoeiweg di C)

    C ds useg js ji diwe}oegdjwe fjilujle mt saoe ndlne}/fepef fjilujles) Wnds ds doxfeoeiweg di aie a` w|a|jts& js fjilujles |ndcn2

    Eodw C sau}ce cage& jig aie a} oa}e awne} }ex}eseiwjwdais2 ojcndie cage& ambecw cage& jig!a} mtwecages)

    E~joxfes2 saoe Fdsx gdjfecws .Fusn$& Szuejk,s C/sumsew Sfjil)

    Eodw C sau}ce cage aift& jig ia awne} }ex}eseiwjwdai) E~joxfes2 Ed``ef& Sjwne}; Eswe}ef)

    C sau}ce cage ds wnei dixuw wa j C caoxdfe}& |ndcn wnei auwxuws `didsneg ojcndie a} ambecw cage) Wnds dsgaie wa ljdi xa}wjmdfdwt .C caoxdfe}s e~dsw `a} iej}ft jff xfjw`a}os$ jig wa jpadg njpdil wa gepefax ojcndie/sxecd`dc cage leie}jwa}s)

    Ui`a}wuijweft& C |js gesdlieg js j x}al}joodil fjilujle& iaw js j caoxdfe} wj}lew fjilujle& jig ds wnusfess wnji dgejf `a} use js ji diwe}oegdjwe fjilujle) Wnds njs feg wa gepefaxoeiw a` C/mjseg diwe}oegdjwefjilujles sucn js C//)

    4=$ C ds j leie}jf/xu}xase& x}acegu}jf& doxe}jwdpe caoxuwe} x}al}joodil fjilujle gepefaxeg di :4

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    34/38

    padg" xw};diw "d ? xw}; !" Doxfdcdw caipe}sdai `}ao padg" wa diw" "!

    a} sdodfj}ft2

    diw "b ? ojffac.sdrea`.diw$ " 5$; !" Doxfdcdw caipe}sdai `}ao padg" wa diw" "!

    Di a}ge} wa ojke wne cage caoxdfe di mawn C jig C++& aie ousw use ji e~xfdcdw cjsw2

    padg" xw};diw "d ? .diw "$ xw};diw "b ? .diw "$ ojffac.sdrea`.diw$ " 5$;

    Jiawne} xa}wjmdfdwt dssue `}ao C wa C++ j}e wne iuoe}aus jggdwdaijf ket|a}gs wnjw C++ diw}aguceg) Wndsojkes C cage wnjw uses wneo js dgeiwd`de}s dipjfdg di C++) @a} e~joxfe2

    sw}ucw weoxfjwe {diw ie|;sw}ucw weoxfjwe" cfjss;

    ;

    ds feljf C cage& muw ds }ebecweg mt j C++ caoxdfe}& sdice wne ket|a}gs -weoxfjwe-& -ie|- jig -cfjss- j}e

    }ese}peg)

    Wne}e j}e ojit awne} C stiwj~es |ndcn j}e dipjfdg a} menjpe gd``e}eiwft di C++ 2

    Wne caooj axe}jwa} cji }esufw di ji -f/pjfue- .j zujiwdwt wnjw cji me useg `a} wne fe`w/njig sdge a` jijssdlioeiw$ di C++& muw iaw di C)C gaes iaw jffa| j ldpei wtxege` wa me guxfdcjweg di wne sjoe scaxe& |ne}ejs C++ jffa|s }eguigjiwwtxege`s)

    Eiuoe}jwdai caiswjiws .eiuo pjfues$ j}e jf|jts a` wtxe diw di C& |ne}ejs wnet j}e gdswdicw wtxes di C++jig ojt njpe sdre gd``e}eiw `}ao diw)

    C++ dgeiwd`de}s j}e iaw jffa|eg wa caiwjdi w|a a} oa}e caisecuwdpe uige}sca}es& |ne}ejs C dgeiwd`de}s ojt)

    C++ jfsa cnjiles saoe C swjigj}g/fdm}j}t `uicwdais wa jgg jggdwdaijf caisw zujfd`de}s& e)l) sw}cn} }ewu}is

    cnj}" di C jig caisw cnj}" di C++)

    Di mawn C jig C++ aie cji ge`die iesweg sw}ucw wtxes& muw wne scaxe ds diwe}x}eweg gd``e}eiwft .di C++& jiesweg sw}ucw ds ge`dieg aift |dwndi wne scaxe!ijoesxjce a` wne auwe} sw}ucw$)

    Iai/x}awawtxe .-K]-/swtfe$ `uicwdai gecfj}jwdais j}e iaw jffa|eg di C++& jfwnauln wnet njpe jfsa meeigex}ecjweg di C sdice :448) Sdodfj}ft& doxfdcdw `uicwdai gecfj}jwdais .usdil `uicwdais wnjw njpe iaw meeigecfj}eg$ j}e iaw jffa|eg di C++& muw njpe jfsa meei gex}ecjweg di C sdice :444)

    C jffa|s sw}ucw& uidai& jig eiuo wtxes wa me gecfj}eg di `uicwdai x}awawtxes& |ne}ejs C++ gaes iaw) Jsw}ucw& uidai& a} eiuo gecfj}jwdai di C++ gecfj}es ji doxfdcdw wtxege`& |ndfe di C dw gaes iaw)

    Di a}ge} wa diwe}od~ C jig C++ cage& jit C++ `uicwdais |ndcn j}e wa me cjffeg `}ao C/caoxdfeg cage ouswme gecfj}eg js e~we}i -C-)

    47$ C}ass caoxdfe}

    J c}ass caoxdfe} ds j caoxdfe} cjxjmfe a` c}ejwdil e~ecuwjmfe cage `a} j xfjw`a}o awne} wnji wne aie ai|ndcn wne c}ass caoxdfe} ds }ui) Sucn j waaf ds njigt |nei aie |jiws wa caoxdfe cage `a} j xfjw`a}o wnjwtau gai,w njpe jccess wa& a} mecjuse dw ds dicaipeideiw a} doxassdmfe wa caoxdfe ai wnjw xfjw`a}o .js ds wnecjse |dwn eomeggeg stsweos& ai |ndcn pj}daus kdigs a` odc}acaiw}affe}s }ui |dwn j odidojf joauiw a`oeoa}t `a} wned} a|i xu}xase$)

    C}ass/caoxdfjwdai ds wtxdcjfft oa}e dipafpeg jig x}aie wa e}}a}s wnji |dwn ijwdpe caoxdfjwdai) Gue wa wnds&c}ass/caoxdfdil ds ia}ojfft aift uwdfdreg d` wne wj}lew ds iaw tew sef`/naswdil .d)e) jmfe wa caoxdfe x}al}jos ai

    37

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    35/38

    dws a|i$& uiswjmfe& a} wne mudfg stsweo ds sdoxft oucn `jswe}) @a} ojit eomeggeg stsweos& c}ass/caoxdfjwdai ds sdoxft wne aift xassdmfe |jt wa mudfg x}al}jos js wne wj}lew nj}g|j}e gaes iaw njpe wne}esau}ces a} cjxjmdfdwdes wa caoxdfe cage ai dws a|i)

    Uses a` c}ass caoxdfe}s

    Wne `uigjoeiwjf use a` j c}ass caoxdfe} ds wa sexj}jwe wne mudfg eipd}aioeiw `}ao wne wj}lew eipd}aioeiw)

    Wnds ds use`uf di j iuome} a` sdwujwdais2

    Eomeggeg caoxuwe}s |ne}e j gepdce njs e~w}eoeft fdodweg }esau}ces) @a} e~joxfe& j odc}a|jpe apei |dffnjpe ji e~w}eoeft sojff caoxuwe} wa }ejg dws waucnxjg jig gaa} seisa}& x}apdge auwxuw wa j gdldwjf gdsxfjtjig sxejke}& jig wa caiw}af wne ojcndie}t `a} caakdil `aag) Wnds caoxuwe} |dff iaw me xa|e}`uf eiauln wa}ui j caoxdfe}& j `dfe stsweo& a} j gepefaxoeiw eipd}aioeiw)

    Caoxdfdil `a} oufwdxfe ojcndies) @a} e~joxfe& j caoxjit ojt |dsn wa suxxa}w sepe}jf gd``e}eiw pe}sdais a`ji axe}jwdil stsweo a} wa suxxa}w sepe}jf gd``e}eiw axe}jwdil stsweos) Mt usdil j c}ass caoxdfe}& j sdilfemudfg eipd}aioeiw cji me ojdiwjdieg wnjw |aufg mudfg `a} ejcn a` wnese wj}lews)

    Caoxdfdil ai j se}pe} `j}o) Sdodfj} wa caoxdfdil `a} oufwdxfe ojcndies& j caoxfdcjweg mudfg wnjw dipafpesojit caoxdfe axe}jwdais cji me e~ecuweg jc}ass jit ojcndie wnjw ds `}ee }elj}gfess a` dws m}jig a} cu}}eiwpe}sdai a` ji axe}jwdil stsweo)Maawsw}jxxdil wa j ie| xfjw`a}o) \nei gepefaxdil sa`w|j}e `a} j ie| xfjw`a}o& a} wne eoufjwa} a` j `uwu}e

    xfjw`a}o& aie uses j c}ass caoxdfe} wa caoxdfe iecessj}t waafs sucn js wne axe}jwdil stsweo jig j ijwdpecaoxdfe})

    Use a` pd}wujf ojcndies .sucn js Bjpj,s BPO$ joefda}jwe saoe a` wne x}amfeos `a} |ndcn c}ass caoxdfe}s|e}e gepefaxeg) Wne pd}wujf ojcndie oewnag jffa|s wne sjoe caoxdfe} auwxuw wa me useg mt mawn wne naswjig wne wj}lew stsweo)

    Wtxdcjfft wne nj}g|j}e j}cndwecwu}e gd``e}s .e)l) caoxdfdil j x}al}jo geswdieg `a} wne ODXS j}cndwecwu}e aiji ~>0 caoxuwe}$ muw c}ass/caoxdfjwdai ds jfsa jxxfdcjmfe |nei aift wne axe}jwdil stsweo eipd}aioeiwgd``e}s& js |nei caoxdfdil j @}eeMSG x}al}jo uige} Fdiu~& a} epei busw wne stsweo fdm}j}t& js |neicaoxdfdil x}al}jos |dwn uCfdmc ai j lfdmc nasw)

    45$ \njw ds j xadiwe}1

    J xadiwe} ds j sxecdjf pj}djmfe wnjw ds useg `a} swa}dil saoe oeoa}t jgg}ess) Sa sdrea`.xadiwe}$ ds sojff jiggexeigs ai axe}jwdai stsweo) @a} \di3= dw ezujfs 7 mtwes) J xadiwe} njs j wtxe -Xadiwe} wa saoe wtxe-) Jxadiwe} cji me caipe}weg wa diwele} pjfue jig diwele} pjfue cji me caipe}weg wa j xadiwe}) Dw ds useg |dgeft diwne \diga|s JXD `uicwdais)

    40$ ojffac!cjffac

    mawn jffacjwe oeoa}t cjffac njs sfdlnwft gd``e}eiw stiwj~ ) Oasw doxa}wjiwft2 cjffac.$ re}as auw jffacjwegoeoa}t& ojffac.$ gaesi,w)

    cjffac.$ j wdit mdw sfa|e}

    Gtijodc oeoa}t jffacjwdai

    #dicfuge 6swgfdm)n9

    diw "`aa.diw i$ {

    diw d[:8_; !" oeoa}t jffacjweg ne}e "!

    diw d=[i_; !" E]]A]2 IAW PJFDG* "!

    35

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    36/38

    diw "b;

    b ? .diw "$ojffac.i " sdrea`.diw$$; !" Jfwe}ijwdpeft2 "!

    !" b ? .diw "$cjffac.i& sdrea`.diw$$; "!

    }ewu}i b;

    !" ds oeoa}t gejffacjweg ne}e; bs iaw "!

    padg mj}.$ {

    diw "j}} ? `aa.:8$;

    j}}[8_ ? :8;

    j}}[:_ ? =8;

    !" ))) ga saoewndil |dwn j}} ))) "!

    `}ee.j}}$; !" gejffacjwe oeoa}t "!

    Iaw cjffdil `}ee.$ fejgs wa oeoa}t fejks *

    4$ Oeoa}t fejks

    J$ Oeoa}t fejks j}e aie a` wne |a}swkdigs a` muls) a`wei& ia nj}o gaie jw jff& epeiwujfft ojt cjuse fail/}uiidil x}al}jo wa c}jsn auw a` oeoa}t&pe}t nj}g wa w}jck ga|i

    Sxecdjf waafs .e)l)pjfl}dig$ e~dsw wa gemul oeoa}t fejks

    44$ Use a` pafjwdfe

    J$ J pj}djmfe snaufg me gecfj}eg pafjwdfe |neiepe} dws pjfue cji me cnjileg mt saoewndil metaig wnecaiw}af a` wne x}al}jo di |ndcn dw jxxej}s& sucn js j caicu}}eiwft e~ecuwdil wn}ejg) Pafjwdfe& cji jxxej}aift aice di j gecfj}jwdai |dwn jit wtxe sxecd`de}; na|epe}& wnet cjiiaw jxxej} j`we} wne `d}sw caooj di joufwdxfe dweo gecfj}jwdai) @a} e~joxfe& wne `affa|dil gecfj}jwdais j}e feljf

    !" Few W geiawes saoe gjwj wtxe "!

    wtxege` pafjwdfe W d;

    pafjwdfe W d;

    W pafjwdfe d ;

    30

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    37/38

    Jig wne `affa|dil gecfj}jwdai ds dffeljf

    W d& pafjwdfe pd ;

    Pafjwdfe zujfd`de}s cji me useg wa cnjile wne menjpda} a` j wtxe) @a} e~joxfe&

    pafjwdfe diw x ? 3;

    gecfj}es jig didwdjfdres ji ambecw |dwn wtxe pafjwdfe diw |nase pjfue |dff me jf|jts }ejg `}ao oeoa}t)

    Use a` pafjwdfe

    / Ji ambecw wnjw ds j oeoa}t/ojxxeg D!A xa}w

    / Ji ambecw pj}djmfe wnjw ds snj}eg mew|eei oufwdxfe caicu}}eiw x}acesses

    / Ji ambecw wnjw ds oagd`deg mt ji diwe}}uxw se}pdce }auwdie

    / Ji juwaojwdc ambecw gecfj}eg di j `uicwdai wnjw cjffs sewbox jig |nase pjfue ds/cnjileg mew|eei wne cjff

    wa sewbox jig j ca}}esxaigdil cjff wa failbox

    :88$ Na| wa }ejg diwele}s `}ao swjigj}g dixuw1

    D |jiij }ejg diwele}s `}ao swjigj}g dixuw e)l) Ketmaj}g )) Diwele}s cji me uxl}jgeg wa fail jfsa sa

    Muw d gaiw |jiij use scji` `uicwdai ))) ds wne}e jit awne} `uicwdai a} ojc}a1

    D useg lewcn ))) muw dws w}uicjwdil diwele} pjfue wa `dw di cnj}jcwe} pjfue ))))

    J$Use scji`& a} `lews + sscji`& a} `lews + jwaf)

    sullesw wnjw tau gai,w use scji` `a} sdilfe cnj} dixuw) scji` ds jfsa caisdge}eg wa me j secu}dwt nafe) Muw wnjwgaesi,w oeji wnjw tau snaufgi,w use dw& |ne}e jxx}ax}djwe)

    Muw& scji` ds iaw waa mjg `a} sw}ejoeg dixuw)

    @a} fdie/mjseg dixuw& scji` ds usujfft dijxx}ax}djwe& esxecdjfft mecjuse dw,s ods/uige}swaag)

    Muw& fdie/mjseg dixuw ds a`wei epdf& jig saoewdoes& luts |na use dw& j}e gadil sa aift mecjuse wned} ge`jufwwe}odijf sewwdils |dwn wne ge`jufw we}odijf a` wned} stsweo j}e cai`dlu}eg sa wnjw wne caisafe dixuw faaks fdke jfdie mjseg wndil)

    Gadil fdie/mjseg dixuw |ne}e dw,s j ijwu}jf diwe}`jce .`a} wne use} jig `a} awne} x}al}jos$ ds ak)

    Gadil fdie/mjseg dixuw epe}t|ne}e ds j laag oeji wa ojke jit jgpjiceg use}& njwe tau} x}al}jodiwe}`jce)

    3

  • 7/23/2019 Q & A From C, C++, Linux, VxWorks

    38/38

    J$ Use`uf |emsdwes

    nwwx2!!|||)}esej}cn)jww)cao!yms!msQ`jz)nwof .Sw}auwsw}ux mfal$nwwx2!!|||)}esej}cn)jww)cao!yms!msQ`jz=)nwof#ape}fajg/gaw

    nwwx2!!|||)oa}e/c)mfalsxaw)cao!nwwx2!!ludgeoe)dwla)cao!jwara`c!nwwx2!!ludgeoe)dwla)cao!jwara`c!#}epdsdaindswa}tnwwx2!!|||)epe}twndil=)cao!dige~)xf1iageQdg?>55>=>fjswiageQdg?8nwwx2!!|||)eskdoa)cao!yscs!ccfjss!k}iawes!wax)nwofnwwx2!!|||)wnecj}ee}xfus)cao!1xjle?}esau}cescjw?:8nwwx2!!|||)axeil}aux)a}l!aifdiexums!884045344!~}jw!~snQcnjx8=)nwof#wjlQ83Q8=Q8>Q83

    nwwx2!!wecn/wuws)mfalsxaw)cao!=880!8>!cQ85)nwof

    nwwx2!!wecn/wuws)mfalsxaw)cao!=880!8>!c)nwof

    nwwx2!!|||)ku}a5ndi)a}l!1ax?gdsxfjtswa}t;sdg?=88:!=!=3!:47577!:34nwwx2!!|||)otcxfus)cao!`a}uo!`a}uoQxasws)jsx1WDG?:=XI?:nwwx2!!|||)bamsg}ejo)cao!di`a!wdxs!}esuoex}ex=33)nwonwwx2!!|||)axei/swg)a}l!bwc:!sc==!|l=:! .`a} C++$nwwx2!!|||)wecniaxfjrj)iew!x}al}joodil!fessai4)xnxnwwx2!!|||)cagex}abecw)cao!wdxs!fapeftxadiwe}s)jsxnwwx2!!cx}al}jooe}s)mfalsxaw)cao!nwwx2!!naoe)jww)iew!ybjckkfedi!c!cQojdi)nwofnwwx2!!use}s)jme})jc)uk!jub!padgojdi)snwofnwwx2!!|||/:=>)dmo)cao!gepefaxe}|a}ks!fdiu~!fdm}j}t!f/oeoa}t!

    3>

    http://www.research.att.com/~bs/bs_faq.htmlhttp://www.research.att.com/~bs/bs_faq2.html#overload-dothttp://www.more-c.blogspot.com/http://guideme.itgo.com/atozofc/http://guideme.itgo.com/atozofc/#revisionhistoryhttp://www.thecareerplus.com/?page=resources&cat=10http://www.open-std.org/jtc1/sc22/wg21/http://cprogrammers.blogspot.com/http://home.att.net/~jackklein/c/c_main.htmlhttp://users.aber.ac.uk/auj/voidmain.shtmlhttp://www.research.att.com/~bs/bs_faq.htmlhttp://www.research.att.com/~bs/bs_faq2.html#overload-dothttp://www.more-c.blogspot.com/http://guideme.itgo.com/atozofc/http://guideme.itgo.com/atozofc/#revisionhistoryhttp://www.thecareerplus.com/?page=resources&cat=10http://www.open-std.org/jtc1/sc22/wg21/http://cprogrammers.blogspot.com/http://home.att.net/~jackklein/c/c_main.htmlhttp://users.aber.ac.uk/auj/voidmain.shtml