In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use annotation symbols in C language". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use annotated symbols in C language.
I. Annotation rules
The compiler replaces the entire comment with a space during compilation
The / / and / * in the string literals. * / does not represent comment symbols
/ *. / Type comments cannot be nested
Let's take a look at this piece of code:
# include int main () {int/*...*/i; char* s = "abcdefgh / / hijklmn"; / / Is it a\ valid comment? In/*...*/t I; return 0;}
The following is the compilation result, and you can see that only 12 lines reported an error:
Here are some improvements to the code according to the compilation rules:
# include int main () {int I; char* s = "abcdefgh / / hijklmn"; int i; return 0;}
So of course in/*...*/t I; will report an error.
2. An interesting question in the notes
What does y=x/*p mean?
The author's intention is to assign the result of * divided by * p to y.
Compiler: use / * as the beginning of a comment and treat all the contents after / * as comments until * / appears.
From the compiler's point of view, comments and other program elements are equal. Therefore, as an engineer, comments should not be taken lightly.
# include int main () {int y = 1; int x = 2; int* p = & x; y = x return;}
The compilation result will report an error as expected:
The solution is to put a space between * and /.
# include int main () {int y = 1; int x = 2; int* p = & x; y = x / * p; return 0;} III, textbook notes
This kind of comment explains the running process of the program on each line and does not make much sense. The comment is used to explain the reason and intention rather than to describe the running process of the program!
IV. Confusing notes
PiForms, I, (void * *) & piForm); if (piForm = = * ppiForm) return I;} return-1;} static _ inline int RootForm_GetFormInsertionIndex (RootForm * me, IForm * * ppiForm) {int delta; if (* ppiForm = = FORM_FIRST) return 0; if (* ppiForm = = FORM_LAST | | * ppiForm = = FORM_DEFAULT) {delta = 1 } else {delta = 0;} return RootForm_GetFormIndex (me, ppiForm) + delta;} static void RootForm_StackChange (IRootForm * po) {DECL (RootForm); IForm* piTopForm = IROOTFORM_GetTopForm (po); LISTENER_Cancel (& me- > mlFormActive); LISTENER_Cancel (& me- > mlFormTopmostNonPopup) / / If there are still forms on the stack Then we need to set up several things: / / 1. The topmost form is the active form / 2. All other forms are not active / 3. The topmost form is being listened to via mlFormActive / 4. The topmost non-popup form is being listened to via mlFormTopmostNonPopup / / 5. The topmost non-popup form and all popup forms on top of it are shown / / 6. Forms below the topmost non-popup form are now shown if (piTopForm) {boolean bFoundTopmostNonPopup = FALSE IModel* piModel = NULL; IForm* pif; / / Logging stack change begin BUIT_LOG ("FORMS EVT: Stack Change Starting...", 1); / / Need to deal with the non-active forms first, then the active form for (pif = piTopForm; pif; pif = IROOTFORM_GetForm (po, pif, FALSE, FALSE)) {boolean bPopup; bPopup = IFORM_GetIsPopup (pif) IFORM_GetFormModel (pif, & piModel); if (piModel) {if (pif! = piTopForm) {RootForm_ShowFormWidget (po, pif, (boolean) (bFoundTopmostNonPopup? FALSE: TRUE), FALSE); if (IFORM_IsActive (pif)) {RootForm_ActivateForm (po, pif, FALSE);}} if (! bPopup & &! bFoundTopmostNonPopup) {IMODEL_AddListenerEx (piModel, & me- > mlFormTopmostNonPopup, (PFNLISTENER) RootForm_UpdateTopmostNonPopupListenerCB, me) If (pif! = piTopForm) / / Only update if not the topmost form since the / / Activate below applies theme again The topmost / / non-popup (but not the top!) Influences the / / background, title ans associated themes RootForm_Update (me, FORMITEM_BACKGROUND | FORMITEM_TITLE | FORMITEM_THEME_BASENAME, pif); bFoundTopmostNonPopup = TRUE;}} RELEASEIF (piModel);} RootForm_ActivateForm (po, piTopForm, TRUE); RootForm_ShowFormWidget (po, piTopForm, TRUE, TRUE); IFORM_GetFormModel (piTopForm, & piModel) If (piModel) IMODEL_AddListenerEx (piModel, & me- > mlFormActive, (PFNLISTENER) RootForm_UpdateActiveListenerCB, me); RELEASEIF (piModel); / / Log that the form is about to be activated-all theme stuff has happened by now) BUIT_LOG ("FORMS EVT: Stack Change Finished", 1);} / / Notify change in stack Form_Notify (ROOTFORM_TO_FORM (me), FORMITEM_STACK) } int RootForm_InsertForm (IRootForm * po, IForm * piForm, IForm * pifBefore) {DECL (RootForm); IWidget * piWidget = 0; IWidget * piwBefore = 0; IForm * pifCurrent; int nrForms, formIndex, nErr; if (! piForm) return EBADPARM; / / Make sure we can insert, get the index we want to insert at formIndex = RootForm_GetFormInsertionIndex (me, & pifBefore); if (formIndex)
< 0) return EBADPARM; nrForms = IVECTORMODEL_Size(me->PiForms); pifCurrent = IROOTFORM_GetTopForm (po); / / Get widget to insert IFORM_GetWidget (piForm, WID_FORM, & piWidget); / / Get widget insertion point. If (formIndex = = nrForms | |! nrForms) {piwBefore = WIDGET_ZTOPMOST;} else if (pifBefore = = FORM_FIRST) {if (me- > piBackground! = NULL) {/ / If we have a background widget, try to insert the form's widget / / above the background widget piwBefore = IROOTCONTAINER_GetWidget (me- > piContainer, me- > piBackground, TRUE, FALSE) If (piwBefore) {/ / Add a reference, so it can be released below. IWIDGET_AddRef (piwBefore);}} if (! piwBefore) {/ / No background widget, insert the form's widget at the bottom. PiwBefore = WIDGET_ZBOTTOMMOST;}} else {IFORM_GetWidget (pifBefore, WID_FORM, & piwBefore);} / / Make sure we have space for the new form nErr = IVECTORMODEL_EnsureCapacity (me- > piForms, MAX (FORMSTACK_MIN, nrForms + 1), FORMSTACK_GROW); / / Now insert if (! nErr & & piWidget & & piwBefore) {WidgetPos pos / / Not really needed here since Activate does this to, but since / / we need to give a position on insert we may as well do it / / right pos.x = me- > rcClient.x; pos.y = me- > rcClient.y; pos.bVisible = (piwBefore = = WIDGET_ZTOPMOST); / / Insert widget into widget stack nErr = IROOTCONTAINER_Insert (me- > piContainer, piWidget, piwBefore, & pos) } if (! nErr) {char* pTheme = 0; / Add form to formstack IVECTORMODEL_InsertAt (me- > piForms, formIndex, piForm); IFORM_AddRef (piForm); / / Set rootform IFORM_SetProperty (piForm, FID_ROOT, (uint32) po); / / Log info IFORM_GetThemeBaseName (ROOTFORM_TO_IFORM (me), & pTheme); pTheme = (pTheme)? PTheme: "(None)"; BUIT_LOG ("FORMS EVT: Insert Set Theme Started for% s", pTheme); / / Set theme on new form IFORM_ApplyTheme (piForm); BUIT_LOG ("FORMS EVT: Insert Set Theme Finished for% s", pTheme); / / RootForm_Update (me, FORMITEM_THEME, piForm); RootForm_StackChange (po);} RELEASEIF (piWidget) If (piwBefore! = WIDGET_ZTOPMOST & & piwBefore! = WIDGET_ZBOTTOMMOST) RELEASEIF (piwBefore); return nErr;} int RootForm_RemoveForm (IRootForm * po, IForm * piForm) {DECL (RootForm); IWidget * piWidget = 0; IForm * piF = 0; int nrForms = 0; int formIndex; boolean bOnlyPopups = 1; if (me- > piForms) nrForms = IVECTORMODEL_Size (me- > piForms) If (piForm = = FORM_ALL) {while (nrForms > 0) {IROOTFORM_RemoveForm (po, FORM_LAST); nrForms = IVECTORMODEL_Size (me- > piForms);}} else {formIndex = RootForm_GetFormIndex (me, & piForm); if (formIndex
< 0) return EBADPARM; IFORM_GetWidget(piForm, WID_FORM, &piWidget); if (piWidget) { IROOTCONTAINER_Remove(me->PiContainer, piWidget);} / Hide form widget RootForm_ShowFormWidget (po, piForm, FALSE, FALSE); / / Deactivate form RootForm_ActivateForm (po, piForm, FALSE); / / Tell it of rootform departure IFORM_SetProperty (piForm, FID_ROOT, 0); / / Delete it from the stack IVECTORMODEL_DeleteAt (me- > piForms, formIndex); RootForm_StackChange (po); RELEASEIF (piWidget) / / Now many forms do we now have? NrForms = IVECTORMODEL_Size (me- > piForms);} / / Cycle through remaining forms to determine type for (piF = IROOTFORM_GetTopForm (po); piF & & bOnlyPopups; piF = IROOTFORM_GetForm (po, piF, FALSE, FALSE)) {bOnlyPopups & = IFORM_GetIsPopup (piF) } if (0 = = nrForms) | | bOnlyPopups) {/ / If we don't have any more forms, or the only forms we do have are popups, / / ensure the title has been cleaned (the title memory is owned by the last full screen form, / / which may no longer exist). If (me- > piTitle) {/ / Release image. Text is owned by form RELEASEIF (me- > titleInfo.piImage); me- > titleInfo.pwText = NULL; / / Set title info IWIDGET_SetImageStaticInfo (me- > piTitle, & me- > titleInfo, 0);} if (0 = = nrForms) {/ / There are no more forms, ensure the softkey labels / / have been cleaned (the softkey memory is owned by the form, which may no / / longer exist). If (me- > piSoftkeys) {IWidget * piKey = NULL; (void) IWIDGET_GetSoftkey (me- > piSoftkeys, PROP_SOFTKEY1, & piKey); if (piKey) {IWIDGET_SetText (piKey, NULL, 0); IWIDGET_Release (piKey); piKey = NULL;} (me- > piSoftkeys, PROP_SOFTKEY2, & piKey) If (piKey) {IWIDGET_SetText (piKey, NULL, 0); IWIDGET_Release (piKey); piKey = NULL;}} else {RootForm_Update (me, FORMITEM_THEME_BASENAME, IROOTFORM_GetTopForm (po));} return AEE_SUCCESS;} void RootForm_GetClientRect (IRootForm * po, IXYContainer * * ppo, AEERect * rc) {DECL (RootForm) If (rc) {* rc = me- > rcClient;} if (ppo & & me- > piContainer) {* ppo = IROOTCONTAINER_TO_IXYCONTAINER (me- > piContainer); IROOTCONTAINER_AddRef (me- > piContainer);} IForm * RootForm_GetForm (IRootForm * po, IForm * pifRef, boolean bNext, boolean bWrap) {DECL (RootForm); IForm * piForm = 0; int nrForms, formIndex; if (me- > piForms = = NULL) return NULL NrForms = IVECTORMODEL_Size (me- > piForms); if (pifRef = = NULL) {formIndex = bNext? 0: nrForms-1; IVECTORMODEL_GetAt (me- > piForms, formIndex, (void * *) & piForm); return piForm;} formIndex = RootForm_GetFormIndex (me, & pifRef); if (formIndex
< 0) return NULL; formIndex += bNext ? 1 : -1; if (formIndex < 0) { formIndex = bWrap ? nrForms - 1 : -1; } else if (formIndex >= nrForms) {formIndex = bWrap? 0:-1;} if (formIndex
< 0) return NULL; IVECTORMODEL_GetAt(me->PiForms, formIndex, (void * *) & piForm); return piForm;} int RootForm_ResolveForm (IRootForm * po, char const * szFormUrl, IForm * * ppiForm) {DECL (RootForm); IWebUtil * piWebUtil = 0; AEECLSID formClsId; int result; UrlParts parts; char * path = 0; if (! ppiForm | |! szFormUrl) return EBADPARM; / Assume failure * ppiForm = 0 / / Parse the URL result = ISHELL_CreateInstance (FORM_SHELL (me), AEECLSID_WEBUTIL, (void * *) & piWebUtil); if (result = = 0) result = IWEBUTIL_ParseUrl (piWebUtil, szFormUrl, & parts); / / Check the scheme if (result = = 0 & (! UP_HASSCHM (& parts) | STRNCMP (parts.cpcSchm,FORM_URL_SCHEME,sizeof (FORM_URL_SCHEME)-1)) result = ESCHEMENOTSUPPORTED / / Do we have a path? If (result = = 0 & (! UP_HASPATH (& parts) | | UP_PATHLEN (& parts) piTitle); RELEASEIF (me- > piSoftkeys); RELEASEIF (me- > piContainer); RELEASEIF (me- > piBackground); RELEASEIF (me- > titleInfo.piImage); RELEASEIF (me- > piForms); RELEASEIF (me- > piActiveWidget); RELEASEIF (me- > piThemeFile); FREEIF (me- > themeFile); Form_Dtor (& me- > base); uint32 RootForm_Release (IRootForm * IRootForm) {po (po) If (FORM_NREFS (me) = = 1) RootForm_Dtor (me); return Form_Release (IROOTFORM_TO_IFORM (po));} int RootForm_QueryInterface (IRootForm * po, AEECLSID clsid, void * * ppo) {if (clsid = = AEEIID_ROOTFORM) {* ppo = po; Form_AddRef (IROOTFORM_TO_IFORM (po)); return AEE_SUCCESS;} return Form_QueryInterface (IROOTFORM_TO_IFORM (po), clsid, ppo) } int RootForm_Construct (RootForm * me, AEEVTBL (IRootForm) * pvt, IModule * piModule, IShell * piShell) {int result; WExtent extent; WidgetPos pos; IDisplay * piDisplay = 0; ICanvas * piCanvas = 0; Form_Ctor (& me- > base, (AEEVTBL (IForm) *) pvt, piModule, piShell, (PFNHANDLER) RootForm_HandleEvent); pos.x = 0; pos.y = 0; pos.bVisible = TRUE; SETWEXTENT (& extent, 0,0) / / Form overrides pvt- > Release = RootForm_Release; pvt- > QueryInterface = RootForm_QueryInterface; / / RootForm definitions pvt- > InsertForm = RootForm_InsertForm; pvt- > RemoveForm = RootForm_RemoveForm; pvt- > GetClientRect = RootForm_GetClientRect; pvt- > GetForm = RootForm_GetForm; pvt- > ResolveForm = RootForm_ResolveForm; result = ISHELL_CreateInstance (piShell, AEECLSID_VECTORMODEL, (void * *) & me- > piForms) If (result = = 0) {IVECTORMODEL_SetPfnFree (me- > piForms, (PFNNOTIFY) RootForm_FreeFormEntry); result = ISHELL_CreateInstance (piShell, AEECLSID_DISPLAY, (void * *) & piDisplay);} if (result = = 0) result = ISHELL_CreateInstance (piShell, AEECLSID_ROOTCONTAINER, (void * *) & me- > piContainer); if (result = = 0) result = IROOTCONTAINER_QueryInterface (me- > piContainer, AEEIID_WIDGET, (void *) & me- > base.piWidget) If (result = = 0) result = ISHELL_CreateInstance (piShell, AEECLSID_RESFILE, (void * *) & me- > piThemeFile); if (result = = 0) result = ISHELL_CreateInstance (piShell, AEECLSID_IMAGEWIDGET, (void * *) & me- > piBackground); if (result = = 0) {IWIDGET_SetFlags (me- > piBackground, IDF_ALIGN_RIGHT | IDF_ALIGN_BOTTOM) / / Insert, extent will be fixed up in SetDisplay below result = IROOTCONTAINER_Insert (me- > piContainer, me- > piBackground, WIDGET_ZBOTTOMMOST, & pos);} if (result = = 0) / / Construct title result = ISHELL_CreateInstance (piShell, AEECLSID_IMAGESTATICWIDGET, (void * *) & me- > piTitle); if (result = = 0) {extent.height = 15; / / Set title font to bold by default. Apps and themes can override it. IWIDGET_SetFontClass (me- > piTitle, AEECLSID_FONTSYSBOLD); IWIDGET_SetShadowOffsetY (me- > piTitle, 0); IWIDGET_SetBorderWidth (me- > piTitle, 0); IWIDGET_SetExtent (me- > piTitle, & extent); / / Add to container result = IROOTCONTAINER_Insert (me- > piContainer, me- > piTitle, WIDGET_ZTOPMOST, & pos) } if (result = = 0) / / Construct Softkeys result = ISHELL_CreateInstance (piShell, AEECLSID_SOFTKEYWIDGET, (void * *) & me- > piSoftkeys); if (result = = 0) {IWIDGET_SetShadowOffsetY (me- > piSoftkeys,-1); IWIDGET_SetBorderWidth (me- > piSoftkeys, 0); IWIDGET_SetExtent (me- > piSoftkeys, & extent); IWIDGET_SetLeftPadding (me- > piSoftkeys, 2); IWIDGET_SetRightPadding (me- > piSoftkeys, 2) / / Insert at 0, 0. Correct positioning will happen in SetDisplay result = IROOTCONTAINER_Insert (me- > piContainer, me- > piSoftkeys, WIDGET_ZTOPMOST, & pos);} if (result = = 0) result = RootForm_SetDisplay (me, piDisplay); if (result = = 0) {char* pTheme = 0; IFORM_SetThemeBaseName (ROOTFORM_TO_IFORM (me), "Root"); IFORM_GetThemeBaseName (ROOTFORM_TO_IFORM (me), & pTheme); pTheme = (pTheme)? PTheme: "(None)"; BUIT_LOG ("FORMS EVT: Construct SetTheme Started for% s", pTheme); IROOTFORM_SetThemeFileName (ROOTFORM_TO_IROOTFORM (me), "theme.bar"); BUIT_LOG ("FORMS EVT: Construct SetTheme Finished for% s", pTheme);} else {RootForm_Dtor (me);} RELEASEIF (piDisplay); RELEASEIF (piCanvas); return result } int RootForm_New (IRootForm * * ppo, IModule * piModule, IShell * piShell) {RootForm * me = MALLOCREC_VTBL (RootForm, IRootForm); int result; * ppo = (IRootForm *) me; if (! me) return ENOMEMORY; result = RootForm_Construct (me, GETVTBL (me, IRootForm), piModule, piShell); if (result! = 0) {* ppo = NULL; FREE (me);} return result } at this point, I believe you have a deeper understanding of "how to use annotation symbols in C language". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.