2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
8 This manual page is licensed under the Creative Commons Attribution-ShareAlike 3.0 United States License (CC BY-SA 3.0
9 US). To view a copy of this license, visit http://creativecommons.org.license/by-sa/3.0/us.
14 xmlns:xi="http://www.w3.org/2001/XInclude">
16 <!-- See http://www.docbook.org/tdg/en/html/refentry.html. -->
19 <refentrytitle>waffle_init</refentrytitle>
20 <manvolnum>3</manvolnum>
24 <refname>waffle_error</refname>
25 <refname>waffle_error_get_info</refname>
26 <refname>waffle_error_get_code</refname>
27 <refname>waffle_error_to_string</refname>
28 <refpurpose>Thread-local error state</refpurpose>
32 <title>Waffle Manual</title>
33 <productname>waffle</productname>
34 <xi:include href="common/author-chad.versace.xml"/>
35 <xi:include href="common/copyright.xml"/>
36 <xi:include href="common/legalnotice.xml"/>
41 <funcsynopsis language="C">
44 #include <waffle.h>
46 enum waffle_error {...};
48 struct waffle_error_info {
49 enum waffle_error code;
51 size_t message_length;
56 <funcdef>const struct waffle_error_info* <function>waffle_error_get_info</function></funcdef>
61 <funcdef>enum waffle_error <function>waffle_error_get_code</function></funcdef>
66 <funcdef>const char* <function>waffle_error_to_string</function></funcdef>
67 <paramdef>enum waffle_error<parameter>e</parameter></paramdef>
74 <title>Description</title>
77 Waffle functions usually return either a <type>bool</type>, in which false indicates failure, or a pointer, in
78 which null indicates failure. In addition to returning a flag indicating failure, most functions also clear and
79 then set some thread-local error state.
82 The only functions that do not alter waffle's error state are listed here and are explicitly documented as such.
83 All functions listed here can be called before waffle has been successfully initialized with
84 <citerefentry><refentrytitle><function>waffle_init</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
90 <term><type>struct waffle_error_info</type></term>
93 This struct contains the user-visible portion of waffle's thread-local error state.
96 <structfield>code</structfield> may be any token from <type>enum waffle_error</type>.
99 <structfield>message</structfield> often contains a descriptive message about the error.
100 It is never null, though it may be the empty string.
103 <structfield>message_length</structfield> is the length of <structfield>message</structfield> according to
104 <citerefentry><refentrytitle><function>strlen</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>.
110 <term><function>waffle_error_to_string()</function></term>
113 Convert a <type>waffle_error</type> token to a string.
114 For example, convert <constant>WAFFLE_ERROR_UNKNOWN</constant> to <code>"WAFFLE_ERROR_UNKNOWN"</code>.
115 Return null if the token is not a valid error token.
118 This function always sets the error code to <constant>WAFFLE_ERROR_NONE</constant>.
125 <term><function>waffle_error_get_info()</function></term>
128 Get information about the current thread's error state.
131 This function never returns null. The returned pointer becomes invalid when the thread-local error state
135 This function does not alter waffle's error state.
141 <term><function>waffle_error_get_code()</function></term>
144 Get the current thread's error code. Calling this function is equivalent to obtaining the error code with
145 <code>waffle_error_get_info()->code</code>.
148 This function does not alter waffle's error state.
154 <term><type>enum waffle_error</type></term>
157 For reference, below is the complete list of waffle's error codes.
162 <term><constant>WAFFLE_NO_ERROR</constant> = 0x00</term>
165 The function succeeded.
171 <term><constant>WAFFLE_ERROR_FATAL</constant> = 0x01</term>
174 Waffle encountered a fatal error. All future waffle calls result in
181 <term><constant>WAFFLE_ERROR_UNKNOWN</constant> = 0x02</term>
184 Waffle encountered an error for which it lacks an error code. This is
185 usually produced when an underlying native call, such as
186 <citerefentry><refentrytitle><function>XOpenDisplay</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>,
187 fails for an unknown reason.
193 <term><constant>WAFFLE_ERROR_INTERNAL</constant> = 0x03</term>
196 You found a bug in waffle. Please report it. The error message, obtained by
197 <function>waffle_error_get_info()</function>, should contain a description of the bug.
203 <term><constant>WAFFLE_ERROR_BAD_ALLOC</constant> = 0x04</term>
206 Waffle failed to allocate memory.
212 <term><constant>WAFFLE_ERROR_NOT_INITIALIZED</constant> = 0x05</term>
215 The failed function requires waffle to be initialized with
216 <citerefentry><refentrytitle><function>waffle_init</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>.
222 <term><constant>WAFFLE_ERROR_ALREADY_INITIALIZED</constant> = 0x06</term>
225 If waffle has already been initialized by a successful call to
226 <citerefentry><refentrytitle><function>waffle_init</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>,
227 then subsequent calls to <function>waffle_init()</function> produce this error.
233 <term><constant>WAFFLE_ERROR_BAD_ATTRIBUTE</constant> = 0x08</term>
236 An unrecognized attribute name or attribute value was passed in an
243 <term><constant>WAFFLE_ERROR_BAD_PARAMETER</constant> = 0x10</term>
246 The failed function was passed an invalid argument.
252 <term><constant>WAFFLE_ERROR_BAD_DISPLAY_MATCH</constant> = 0x11</term>
255 The waffle objects passed to the failed function belong to different
262 <term><constant>WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM</constant> = 0x12</term>
265 The requested action is unsupported on the current system or platform, but is otherwise valid.
268 For example, attempting to choose a <type>waffle_config</type> whose API is OpenGL ES1 on a system
269 that doesn't OpenGL ES1 will produce this error.
275 <term><constant>WAFFLE_ERROR_BUILT_WITHOUT_SUPPORT</constant> = 0x13</term>
278 Waffle was built without support for the requested action.
281 For example, if waffle was built without support for GBM, then calling <code>waffle_init()</code>
282 with attribute <code>WAFFLE_PLATFORM=WAFFLE_PLATFORM_GBM</code> will produce this error.
296 <xi:include href="common/issues.xml"/>
299 <title>See Also</title>
301 <citerefentry><refentrytitle>waffle</refentrytitle><manvolnum>7</manvolnum></citerefentry>
308 vim:tw=120 et ts=2 sw=2: