Skip to content

Commit ff482b8

Browse files
committed
Add flag to control error output format
1 parent 0d7504c commit ff482b8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

source/common.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ struct comment
104104
//
105105
struct error
106106
{
107+
// Controls whether we print `FILE:line:col: error:` or `FILE(line,col):
108+
// error:`. Need to integrate with editors that jump to errors, etc.
109+
// TODO: This should become a compiler flag.
110+
#ifdef _MSC_VER
111+
static constexpr bool print_colon_errors = false;
112+
#else
113+
static constexpr bool print_colon_errors = true;
114+
#endif
115+
107116
source_position where;
108117
std::string msg;
109118
bool internal = false;
@@ -116,11 +125,19 @@ struct error
116125
{
117126
o << file ;
118127
if (where.lineno > 0) {
119-
o << "("<< (where.lineno);
120-
if (where.colno >= 0) {
121-
o << "," << where.colno;
128+
if (print_colon_errors) {
129+
o << ":"<< (where.lineno);
130+
if (where.colno >= 0) {
131+
o << ":" << where.colno;
132+
}
133+
}
134+
else {
135+
o << "("<< (where.lineno);
136+
if (where.colno >= 0) {
137+
o << "," << where.colno;
138+
}
139+
o << ")";
122140
}
123-
o << ")";
124141
}
125142
o << ":";
126143
if (internal) {

0 commit comments

Comments
 (0)