Last active
January 19, 2025 10:53
-
-
Save dlOuOlb/36ca16297562d32cf684ac100e38db77 to your computer and use it in GitHub Desktop.
An example of XML documentation comments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #if !__STDC__ || __STDC_VERSION__ < 199901L || !__STDC_HOSTED__ | |
| # error "This example requires a C99 compiler with a conforming hosted implementation." | |
| #else | |
| # include <stdio.h> /* puts */ | |
| # include <stdlib.h> /* EXIT_(FAILURE|SUCCESS) */ | |
| /// <summary>Every C program coded to run in a hosted execution environment contains the definition (not the prototype) of a function named <see cref="main"/>, which is the designated start of the program.</summary> | |
| /// <returns>If the return statement is used, the return value is used as the argument to the implicit call to <see cref="exit"/>() (see below for details). The values zero and <see cref="EXIT_SUCCESS"/> indicate successful termination, the value <see cref="EXIT_FAILURE"/> indicates unsuccessful termination.</returns> | |
| /// <param name="argc">Non-negative value representing the number of arguments passed to the program from the environment in which the program is run.</param> | |
| /// <param name="argv">Pointer to the first element of an array of <paramref name="argc"/> + 1 pointers, of which the last one is null and the previous ones, if any, point to strings that represent the arguments passed to the program from the host environment. If <paramref name="argv"/>[0] is not a null pointer (or, equivalently, if <paramref name="argc"/> > 0), it points to a string that represents the program name, which is empty if the program name is not available from the host environment.</param> | |
| /// <remarks> | |
| /// <para>The <see cref="main"/> function is called at program startup, after all objects with static storage duration are initialized. It is the designated entry point to a program that is executed in a hosted environment (that is, with an operating system). The name and type of the entry point to any freestanding program (boot loaders, OS kernels, etc) are implementation-defined.</para> | |
| /// <para>The parameters of the two-parameter form of the <see cref="main"/> function allow arbitrary multibyte character strings to be passed from the execution environment (these are typically known as command line arguments). The pointers <paramref name="argv"/>[1] .. <paramref name="argv"/>[<paramref name="argc"/>-1] point at the first characters in each of these strings. <paramref name="argv"/>[0] (if non-null) is the pointer to the initial character of a null-terminated multibyte string that represents the name used to invoke the program itself (or, if this is not supported by the host environment, <paramref name="argv"/>[0][0] is guaranteed to be zero).</para> | |
| /// <para>If the host environment cannot supply both lowercase and uppercase letters, the command line arguments are converted to lowercase.</para> | |
| /// <para>The strings are modifiable, and any modifications made persist until program termination, although these modifications do not propagate back to the host environment: they can be used, for example, with <see cref="strtok"/>.</para> | |
| /// <para>The size of the array pointed to by <paramref name="argv"/> is at least <paramref name="argc"/>+1, and the last element, <paramref name="argv"/>[<paramref name="argc"/>], is guaranteed to be a null pointer.</para> | |
| /// <para>The <see cref="main"/> function has several special properties: | |
| /// <list type="number"> | |
| /// <item>A prototype for this function cannot be supplied by the program.</item> | |
| /// <item>If the return type of the <see cref="main"/> function is compatible with <see langword="int"/>, then the return from the initial call to <see cref="main"/> (but not the return from any subsequent, recursive, call) is equivalent to executing the <see cref="exit"/> function, with the value that the <see cref="main"/> function is returning passed as the argument (which then calls the functions registered with <see cref="atexit"/>, flushes and closes all streams, and deletes the files created with <see cref="tmpfile"/>, and returns control to the execution environment).</item> | |
| /// <item>If the return type of the <see cref="main"/> function is not compatible with <see langword="int"/> (e.g. <c>void main(void)</c>), the value returned to the host environment is unspecified. If the return type is compatible with int and control reaches the terminating <c>}</c>, the value returned to the environment is the same as if executing <c>return 0;</c>.</item> | |
| /// </list> | |
| /// </para> | |
| /// </remarks> | |
| /// <seealso href="https://en.cppreference.com/w/c/language/main_function">Main function</seealso> | |
| /// <seealso href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/">Documentation comments</seealso> | |
| /// <seealso href="https://learn.microsoft.com/en-us/cpp/build/reference/xml-documentation-visual-cpp">XML documentation (Visual C++)</seealso> | |
| extern signed int main( signed int argc, char **argv ) | |
| { | |
| if( argc < 0 ) | |
| return EXIT_FAILURE; | |
| else if( argc == 0 ) | |
| return EXIT_SUCCESS; | |
| else if( puts( *argv ) < 0 ) | |
| return EXIT_FAILURE; | |
| else | |
| return main( --argc, ++argv ); | |
| } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment