Indentation fix, cleanup.
[AROS.git] / compiler / stdc / __stdcio_assert.c
blob664342d7625bd91729626b8ddd9540893dfcb513
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function assert() autodoc and stdcio.library support function
6 */
8 /*****************************************************************************
10 NAME
11 #include <assert.h>
13 void assert (
15 SYNOPSIS
16 expr)
18 FUNCTION
19 Evaluates the expression expr and if it's FALSE or NULL, then
20 printf a message and aborts the program. The message will
21 contain the expression, the name of the file with the assert
22 in it and the line in the file.
24 INPUTS
25 expr - The expression to evaluate. The type of the expression does
26 not matter, only if it's zero/NULL or not.
28 RESULT
29 The function doesn't return.
31 NOTES
32 Normally the output is sent to stderr and thus this code should
33 only be called from processes with the context of the process
34 available.
35 In low level modules it is advised to use the ASSERT() macro for
36 aros/debug.h.
37 As a last resort one can use the normal assert() macro but link
38 with the kernelassert static link library to get a version that
39 also outputs to kernel debug output.
40 With this assert also an Alert will be generated in place of abort of
41 the program.
43 EXAMPLE
44 // Make sure that x equals 1
45 assert (x==1);
47 BUGS
49 SEE ALSO
51 INTERNALS
53 ******************************************************************************/
55 #include <assert.h>
56 #include <stdio.h>
57 #include <stdlib.h>
59 /*****************************************************************************
61 NAME */
62 #include <assert.h>
64 void __stdcio_assert (
66 /* SYNOPSIS */
67 const char * expr,
68 const char * file,
69 unsigned int line)
71 /* FUNCTION
72 This is a function that is used for implementation of the C99 assert()
73 function.
75 INPUTS
76 expr - The expression to evaluate. The type of the expression does
77 not matter, only if its zero/NULL or not.
78 file - Name of the source file.
79 line - Line number of assert() call.
81 RESULT
82 The function doesn't return.
84 NOTES
85 Different versions of this function are available. This function
86 is used when a program is using stdcio.library and not
87 posixc.library.
89 EXAMPLE
91 BUGS
93 SEE ALSO
94 assert()
96 INTERNALS
98 ******************************************************************************/
100 fprintf (stderr, "Assertion (%s) failed in %s:%u\n", expr, file, line);
101 abort();
102 } /* assert */