Doxygen
Loading...
Searching...
No Matches
message.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2023 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef MESSAGE_H
17#define MESSAGE_H
18
19#include <cstdarg>
20#include "qcstring.h"
21#include "util.h"
22
23#ifdef __GNUC__
24#define PRINTFLIKE(FORMAT, PARAM ) __attribute__((format(printf, FORMAT, PARAM)))
25#else
26#define PRINTFLIKE(FORMAT, PARAM )
27#endif
28
29extern void msg(const char *fmt, ...) PRINTFLIKE(1,2);
30extern void warn_(const QCString &file,int line,const char *fmt, ...) PRINTFLIKE(3, 4);
31extern void va_warn(const QCString &file, int line, const char* fmt, va_list args);
32extern void warn_undoc_(const QCString &file,int line,const char *fmt, ...) PRINTFLIKE(3, 4);
33extern void warn_incomplete_doc_(const QCString &file,int line,const char *fmt, ...) PRINTFLIKE(3, 4);
34extern void warn_doc_error_(const QCString &file,int line,const char *fmt, ...) PRINTFLIKE(3, 4);
35extern void warn_uncond_(const char *fmt, ...) PRINTFLIKE(1, 2);
36extern void err_(const char *fmt, ...) PRINTFLIKE(1, 2);
37extern void err_full_(const QCString &file,int line,const char *fmt, ...) PRINTFLIKE(3, 4);
38extern void term_(const char *fmt, ...) PRINTFLIKE(1, 2);
39extern QCString warn_line(const QCString &file,int line);
41void warn_flush();
42extern void finishWarnExit();
43
44#undef PRINTFLIKE
45
46// N is size including 0-terminal
47template<std::size_t N>
48constexpr bool has_newline_at_end(const char (&str)[N])
49{
50 return str[N-2]=='\n';
51}
52
53#define msg_no_newline_allowed(x) \
54 static_assert(!has_newline_at_end(x),"text: \"" x "\" should not have \\n at end");
55
56#define msg_newline_required(x) \
57 static_assert(has_newline_at_end(x),"text: \"" x "\" should have \\n at end");
58
59#define warn(file,line,fmt,...) do { \
60 msg_no_newline_allowed(fmt); \
61 warn_(removeLongPathMarker(file),line,fmt,##__VA_ARGS__); \
62 } while(0)
63
64#define warn_undoc(file,line,fmt,...) do { \
65 msg_no_newline_allowed(fmt); \
66 warn_undoc_(removeLongPathMarker(file),line,fmt,##__VA_ARGS__); \
67 } while(0)
68
69#define warn_incomplete_doc(file,line,fmt,...) do { \
70 msg_no_newline_allowed(fmt); \
71 warn_incomplete_doc_(removeLongPathMarker(file),line,fmt,##__VA_ARGS__); \
72 } while(0)
73
74#define warn_doc_error(file,line,fmt,...) do { \
75 msg_no_newline_allowed(fmt); \
76 warn_doc_error_(removeLongPathMarker(file),line,fmt,##__VA_ARGS__); \
77 } while(0)
78
79#define warn_uncond(fmt,...) do { \
80 msg_newline_required(fmt); \
81 warn_uncond_(fmt,##__VA_ARGS__); \
82 } while(0)
83
84#define err(fmt,...) do { \
85 msg_newline_required(fmt); \
86 err_(fmt,##__VA_ARGS__); \
87 } while(0)
88
89#define err_full(file,line,fmt,...) do { \
90 msg_no_newline_allowed(fmt); \
91 err_full_(removeLongPathMarker(file),line,fmt,##__VA_ARGS__); \
92 } while(0)
93
94#define term(fmt,...) do { \
95 msg_newline_required(fmt); \
96 term_(fmt,##__VA_ARGS__); \
97 } while(0)
98
99#endif // MESSAGE_H
100
This is an alternative implementation of QCString.
Definition qcstring.h:101
void err_(const char *fmt,...)
Definition message.cpp:263
void warn_uncond_(const char *fmt,...)
Definition message.cpp:254
QCString warn_line(const QCString &file, int line)
Definition message.cpp:205
void err_full_(const QCString &file, int line, const char *fmt,...)
Definition message.cpp:272
void warn_(const QCString &file, int line, const char *fmt,...)
Definition message.cpp:217
void warn_incomplete_doc_(const QCString &file, int line, const char *fmt,...)
Definition message.cpp:238
void va_warn(const QCString &file, int line, const char *fmt, va_list args)
Definition message.cpp:225
void initWarningFormat()
Definition message.cpp:41
void warn_flush()
Definition message.cpp:303
void warn_doc_error_(const QCString &file, int line, const char *fmt,...)
Definition message.cpp:246
void warn_undoc_(const QCString &file, int line, const char *fmt,...)
Definition message.cpp:230
void term_(const char *fmt,...)
Definition message.cpp:280
void finishWarnExit()
Definition message.cpp:310
void msg(const char *fmt,...) PRINTFLIKE(1
constexpr bool has_newline_at_end(const char(&str)[N])
Definition message.h:48
#define PRINTFLIKE(FORMAT, PARAM)
Definition message.h:26
Definition trace.h:153
A bunch of utility functions.