📄 ref.define.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE>define</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="The eCos Component Writer's Guide"HREF="cdl-guide.html"><LINKREL="UP"TITLE="CDL Language Specification"HREF="reference.html"><LINKREL="PREVIOUS"TITLE="default_value"HREF="ref.default-value.html"><LINKREL="NEXT"TITLE="define_format"HREF="ref.define-format.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">The <SPANCLASS="APPLICATION">eCos</SPAN> Component Writer's Guide</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="ref.default-value.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="ref.define-format.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="REF.DEFINE"><SPANCLASS="PROPERTY">define</SPAN></H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN3980"></A><H2>Name</H2>Property <SPANCLASS="PROPERTY">define</SPAN> -- Specify additional <TTCLASS="LITERAL">#define</TT> symbols thatshould go into the owning package's configuration header file.</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN3985"><H2>Synopsis</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="SYNOPSIS">cdl_option <name> { define [-file=<filename>] [-format=<format>] <symbol> …}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN3987"></A><H2>Description</H2><P>Normally the configuration system generates a single<TTCLASS="LITERAL">#define</TT> for each option that is active and enabled,with the defined symbol being the name of the option. These<TTCLASS="LITERAL">#define's</TT> go to the package's own configurationheader file, for example <TTCLASS="FILENAME">pkgconf/kernel.h</TT>for kernel configuration options. For the majority of options this issufficient. Sometimes it is useful to have more control over which<TTCLASS="LITERAL">#define's</TT> get generated.</P><P>The <SPANCLASS="PROPERTY">define</SPAN> property can be used to generate an addition<TTCLASS="LITERAL">#define</TT> if the option is both active and enabled,for example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_option CYGNUM_LIBC_STDIO_FOPEN_MAX { … define FOPEN_MAX}</PRE></TD></TR></TABLE><P>If this option is given the value 40 then the following<TTCLASS="LITERAL">#define's</TT> will be generated in the configurationheader <TTCLASS="FILENAME">pkgconf/libc.h</TT>:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="SCREEN">#define CYGNUM_LIBC_STDIO_FOPEN_MAX 40#define FOPEN_MAX 40</PRE></TD></TR></TABLE><P>The default <TTCLASS="LITERAL">#define</TT> can be suppressed if desiredusing the <SPANCLASS="PROPERTY">no_define</SPAN> property. This is useful if the symbol shouldonly be defined in<TTCLASS="FILENAME">pkgconf/system.h</TT> and not inthe package's own configuration header file. The value that will beused for this <TTCLASS="LITERAL">#define</TT> is the same as for thedefault one, and depends on the option's flavor as follows:</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><TTCLASS="LITERAL">flavor none</TT></DT><DD><P>Options with this flavor are always enabled and have no value, so theconstant <TTCLASS="LITERAL">1</TT> will be used.</P></DD><DT><TTCLASS="LITERAL">flavor bool</TT></DT><DD><P>If the option is disabled then no <TTCLASS="LITERAL">#define</TT> will begenerated. Otherwise the constant <TTCLASS="LITERAL">1</TT> will be used.</P></DD><DT><TTCLASS="LITERAL">flavor booldata</TT></DT><DD><P>If the option is disabled then no <TTCLASS="LITERAL">#define</TT> will begenerated. Otherwise the option's current value will be used.</P></DD><DT><TTCLASS="LITERAL">flavor data</TT></DT><DD><P>The option's current value will be used.</P></DD></DL></DIV><P>For active options with the <TTCLASS="LITERAL">data</TT> flavor, and foractive and enabled options with the <TTCLASS="LITERAL">booldata</TT>flavor, either one or two <TTCLASS="LITERAL">#define's</TT> will begenerated. These take the following forms:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#define <symbol> <value>#define <symbol>_<value></PRE></TD></TR></TABLE><P>For the first <TTCLASS="LITERAL">#define</TT> it is possible to control theformat used for the value using a<TTCLASS="LITERAL">-format=<format></TT> option. For example, thefollowing can be used to output some configuration data as a C string:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_option <name> { … define -format="\\\"%s\\\"" <symbol>}</PRE></TD></TR></TABLE><P>The implementation of this facility involves concatenating theTcl command <TTCLASS="LITERAL">format</TT>, the format string, and thestring representation of the option's value, and evaluating this in aTcl interpreter. Therefore the format string will be processed twiceby a Tcl parser, and appropriate care has to be taken with quoting.</P><P>The second <TTCLASS="LITERAL">#define</TT> will be generated only if is avalid C preprocessor macro symbol. By default the symbols generated by<SPANCLASS="PROPERTY">define</SPAN> properties will end up in the package's own configurationheader file. The <TTCLASS="LITERAL">-file</TT> option can be used tospecify an alternative destination. At the time of writing the onlyvalid alternative definition is <TTCLASS="LITERAL">-file=system.h</TT>,which will send the output to the global configuration header file<TTCLASS="FILENAME">pkgconf/system.h</TT>.</P><DIVCLASS="CAUTION"><P></P><TABLECLASS="CAUTION"BORDER="1"WIDTH="100%"><TR><TDALIGN="CENTER"><B>Caution</B></TD></TR><TR><TDALIGN="LEFT"><P>Care has to be taken with the <TTCLASS="LITERAL">-format</TT> option.Because the Tcl interpreter's <TTCLASS="LITERAL">format</TT> command isused, this property is subject to any problems with the implementationof this in the Tcl library. Generally there should be no problems withstring data or with integers up to 32 bits, but there may well beproblems if 64-bit data is involved. This issue may be addressed in afuture release.</P></TD></TR></TABLE></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="AEN4053"></A><H2>Example</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_component CYG_HAL_STARTUP { display "Startup type" flavor data legal_values {"RAM" "ROM" } default_value {"RAM"} no_define define -file=system.h CYG_HAL_STARTUP …}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN4056"></A><H2>See Also</H2><P>Properties <AHREF="ref.define-format.html"><SPANCLASS="PROPERTY">define_format</SPAN></A>,<AHREF="ref.define-header.html"><SPANCLASS="PROPERTY">define_header</SPAN></A>,<AHREF="ref.define-proc.html"><SPANCLASS="PROPERTY">define_proc</SPAN></A>,<AHREF="ref.if-define.html"><SPANCLASS="PROPERTY">if_define</SPAN></A> and<AHREF="ref.no-define.html"><SPANCLASS="PROPERTY">no_define</SPAN></A>.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="ref.default-value.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="cdl-guide.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="ref.define-format.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><SPANCLASS="PROPERTY">default_value</SPAN></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="reference.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><SPANCLASS="PROPERTY">define_format</SPAN></TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -