Difference between revisions of "Template:Csig"

From Maths
Jump to: navigation, search
m (Testing six arged version)
(Added pre section, documentation and examples, leaving "sample" at top for now due to laziness)
Line 1: Line 1:
{{cs|1={{echo|1={{{1|<noinclude>int</noinclude>}}}}} {{echo|1={{{2|<noinclude>printf</noinclude>}}}}}<!--
+
{{cs|1={{#if:{{{pre|}}}|{{{pre|}}} <nowiki/>|}}{{echo|1={{{1|<noinclude>int</noinclude>}}}}} {{echo|1={{{2|<noinclude>printf</noinclude>}}}}}<!--
  
 
-->{{#if:{{{3|<noinclude>const char*</noinclude>}}}{{{4|<noinclude>format</noinclude>}}}<!--
 
-->{{#if:{{{3|<noinclude>const char*</noinclude>}}}{{{4|<noinclude>format</noinclude>}}}<!--
Line 48: Line 48:
 
--> {{{post|}}}<!--
 
--> {{{post|}}}<!--
  
-->}}
+
-->}}<noinclude>
 +
==Usage==
 +
Currently supports up to 6 arguments, you may use {{C|pre}} and {{C|post}} to make things appear before and after (with a space between them and the body, if present), arguments go as follows:
 +
# return or type (eg {{C|int}})
 +
# symbol name (eg {{C|printf}})
 +
# arg1 - type (eg {{C|const char*}})
 +
#* If not present, then no brackets are rendered after the symbol name, for a variable definition
 +
#* If present but empty then brackets are shown, this is how you'd achieve a function with no arguments over a variable
 +
# arg1 - name
 +
# arg2 - type
 +
# arg2 - name
 +
# arg3 - type
 +
# arg4 - name
 +
and so on.
 +
 
 +
An argument is considered present if the type/name arguments are ''not both empty'', so an empty type with the name as {{C|...}} is valid, for example varadic functions (c-style)
 +
==[[/Example|Examples]]==
 +
{{/Example}}
 +
==Family==
 +
Think of any {{C|*_t}} versions as "template" - to be used alone, without the {{C|_t}} at the end they may be styling (only csig and cs are designed to be used alone and lack a {{C|_t}} to indicate this)
 +
* [[template:cprim]] - used within [[template:csig]] or [[template:cs]] to style primitive types.
 +
** [[template:cprim_t]] - standalone version, used inline, rather than inside csig or cs
 +
* [[template:ckw]] - used within csig or cs
 +
** [[template:ckw_t]] - standalone version
 +
 
 +
</noinclude>

Revision as of 08:30, 1 October 2017

int printf()

Usage

Currently supports up to 6 arguments, you may use pre and post to make things appear before and after (with a space between them and the body, if present), arguments go as follows:

  1. return or type (eg int)
  2. symbol name (eg printf)
  3. arg1 - type (eg const char*)
    • If not present, then no brackets are rendered after the symbol name, for a variable definition
    • If present but empty then brackets are shown, this is how you'd achieve a function with no arguments over a variable
  4. arg1 - name
  5. arg2 - type
  6. arg2 - name
  7. arg3 - type
  8. arg4 - name

and so on.

An argument is considered present if the type/name arguments are not both empty, so an empty type with the name as ... is valid, for example varadic functions (c-style)

Examples

  • int printf(const char* format, ...)
  • int printf(const char* format, ...)
  • int errno __attribute__((aligned(16)))
  • pid_t getpid()
  • long:
    • int lots_of_args(a b, c d, e f, g h) __attribute__((noreturn))

Family

Think of any *_t versions as "template" - to be used alone, without the _t at the end they may be styling (only csig and cs are designed to be used alone and lack a _t to indicate this)