本文整理汇总了C++中gc::file方法的典型用法代码示例。如果您正苦于以下问题:C++ gc::file方法的具体用法?C++ gc::file怎么用?C++ gc::file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gc
的用法示例。
在下文中一共展示了gc::file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: error
void ErrorReporter::error(gc<SourcePos> pos, const char* format, ...)
{
// If we're just waiting for more input, don't show any errors.
if (needMoreLines_) return;
numErrors_++;
// TODO(bob): Hackish. Need to figure out if we want C-style, C++-style or
// Magpie GC strings.
char message[512];
va_list args;
va_start(args, format);
vsprintf(message, format, args);
va_end(args);
// If we don't have any position information, just show the message.
if (pos.isNull())
{
std::cerr << "Error: " << message << std::endl;
return;
}
std::cerr << "[" << pos->file()->path() << "] Error: " << message << std::endl;
if (pos->startLine() == pos->endLine())
{
// Show the line and highlight the error.
std::cerr << pos->startLine() << ": "
<< pos->file()->getLine(pos->startLine()) << std::endl;
// TODO(bob): Lame hack!
int line = pos->startLine();
while (line > 0)
{
std::cerr << " ";
line /= 10;
}
std::cerr << " ";
for (int i = 1; i < pos->endCol(); i++)
{
std::cerr << (i < pos->startCol() ? " " : "^");
}
std::cerr << std::endl;
}
else
{
// Show all of the lines.
for (int i = pos->startLine(); i <= pos->endLine(); i++)
{
// TODO(bob): Should pad line number so they all line up.
std::cerr << i << ": " << pos->file()->getLine(i) << std::endl;
}
}
}