2 Copyright (C) 2001-2010, Parrot Foundation.
7 src/warnings.c - Warning and error reporting
11 Parrot C<STRING> and C string versions of a function to print warning/error
20 #include "parrot/parrot.h"
24 /* HEADERIZER HFILE: include/parrot/warnings.h */
26 /* HEADERIZER BEGIN: static */
27 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
29 static INTVAL
print_warning(PARROT_INTERP
, ARGIN_NULLOK(STRING
*msg
))
30 __attribute__nonnull__(1);
32 #define ASSERT_ARGS_print_warning __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
33 PARROT_ASSERT_ARG(interp))
34 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
35 /* HEADERIZER END: static */
39 =item C<void print_pbc_location(PARROT_INTERP)>
41 Prints the bytecode location of the warning or error to C<Parrot_io_STDERR>.
49 print_pbc_location(PARROT_INTERP
)
51 ASSERT_ARGS(print_pbc_location
)
52 Interp
* const tracer
= (interp
->pdb
&& interp
->pdb
->debugger
) ?
53 interp
->pdb
->debugger
:
55 Parrot_io_eprintf(tracer
, "%Ss\n",
56 Parrot_Context_infostr(interp
, CURRENT_CONTEXT(interp
)));
61 =item C<static INTVAL print_warning(PARROT_INTERP, STRING *msg)>
63 Prints the warning message and the bytecode location.
70 print_warning(PARROT_INTERP
, ARGIN_NULLOK(STRING
*msg
))
72 ASSERT_ARGS(print_warning
)
74 Parrot_io_puts(interp
, Parrot_io_STDERR(interp
), "Unknown warning\n");
76 Parrot_io_putps(interp
, Parrot_io_STDERR(interp
), msg
);
77 if (string_ord(interp
, msg
, -1) != '\n')
78 Parrot_io_eprintf(interp
, "%c", '\n');
80 print_pbc_location(interp
);
88 =head2 Parrot Warnings Interface
92 =item C<INTVAL Parrot_warn(PARROT_INTERP, INTVAL warnclass, const char *message,
95 The Parrot C string warning/error reporter.
97 Returns 2 on error, 1 on success.
99 C<message, ..> can be a C<Parrot_vsprintf_c()> format with arguments.
106 PARROT_IGNORABLE_RESULT
108 Parrot_warn(PARROT_INTERP
, INTVAL warnclass
,
109 ARGIN(const char *message
), ...)
111 ASSERT_ARGS(Parrot_warn
)
112 if (!PARROT_WARNINGS_test(interp
, warnclass
))
118 va_start(args
, message
);
119 targ
= Parrot_vsprintf_c(interp
, message
, args
);
121 return print_warning(interp
, targ
);
127 =item C<void Parrot_warn_deprecated(PARROT_INTERP, const char *message)>
129 Warn about use of a deprecated feature
131 C<message> is a C string.
139 Parrot_warn_deprecated(PARROT_INTERP
, ARGIN(const char *message
))
141 ASSERT_ARGS(Parrot_warn_deprecated
)
143 if (PARROT_WARNINGS_test(interp
, PARROT_WARNINGS_DEPRECATED_FLAG
)) {
144 STRING
*msg
= Parrot_sprintf_c(interp
, "WARNING: %s\n", message
);
145 print_warning(interp
, msg
);
155 F<include/parrot/warnings.h>.
164 * c-file-style: "parrot"
166 * vim: expandtab shiftwidth=4: