小编CHA*_*KRI的帖子

如何在C++程序中获取错误行号

我想处理我的c ++程序中的错误,所以我创建了一些异常类来管理这些错误,但是我想指定程序中哪一行发生了错误.

我将LINE宏传递给我的异常类的构造函数.

例如:

void f(int i){ // LINE A
  if(i<0)
    throw(OutOfRange("message", __LINE__); // LINE B
}

void main(){

  try{
    f(-6); // LINE C
  }
  catch(const OutOfRange& error){
    //do something
  }

}
Run Code Online (Sandbox Code Playgroud)

在这个例子中,我只能获得LINE B编号,但我想获得LINE A和LINE C编号.

任何想法,在哪里以及如何使用LINE宏?

谢谢.

c++ exception line

12
推荐指数
1
解决办法
1万
查看次数

将qwt从5.2.1更新到6.0.0

我正在尝试将qwt从5.2.1更新到6.0.0版本,但是当我编译我的程序时,我得到了一个错误列表.请帮忙.

这是错误列表:

src/../include/../include/scalepicker.h:7:33: error: qwt_double_interval.h: No such file or directory
In file included from src/plot.cpp:13:
src/../include/qwt_plot_rescaler.h:14:29: error: qwt_double_rect.h: No such file or directory
In file included from src/../include/plot.h:9,
                 from src/plot.cpp:1:
src/../include/plotintervalcurve.h:28: error: expected ‘,’ or ‘...’ before ‘<’ token
src/../include/plotintervalcurve.h:28: error: ISO C++ forbids declaration of ‘QwtArray’ with no type
src/../include/plotintervalcurve.h:51: error: ‘QwtDoubleRect’ does not name a type
In file included from src/../include/../../../include/../Glass/include/glass.h:8,
                 from src/../include/../../../include/globGlass.h:5,
                 from src/../include/splinedata.h:6,
                 from src/../include/plot.h:10,
                 from src/plot.cpp:1:
src/../include/../../../include/../Glass/include/../../Utils/include/geometry.h:125: warning: unused parameter ‘a’
src/../include/../../../include/../Glass/include/../../Utils/include/geometry.h:125: warning: unused parameter …
Run Code Online (Sandbox Code Playgroud)

c++ qwt

4
推荐指数
1
解决办法
3753
查看次数

标签 统计

c++ ×2

exception ×1

line ×1

qwt ×1