C ++异常二进制兼容性 [英] C++ exceptions binary compatibility

查看:149
本文介绍了C ++异常二进制兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目使用2个不同的C ++编译器,g ++和nvcc(cuda编译器)。
我注意到从nvcc对象文件抛出的异常没有在g ++对象文件中捕获。

my project uses 2 different C++ compilers, g++ and nvcc (cuda compiler). I have noticed exception thrown from nvcc object files are not caught in g++ object files.

是C ++异常,应该是在同一台机器上兼容二进制?
可能会导致这种行为?

are C++ exceptions supposed to be binary compatible in the same machine? what can cause such behavior?

try { kernel_= new cuda:: Kernel(); }
catch (...) { kernel_= NULL; }

// nvcc object
cuda:: Kernel:: Kernel () {
  ...
  if (! impl_) throw;
}

其他一切似乎都有效(C ++对象,操作符)。说实话,我不知道异常非常好,所以也许上面的代码中有错误。

everything else seems to work (C++ objects, operators). To be honest I do not know exceptions very well so maybe there is mistake in the code above.

推荐答案

nvcc是一个包装器一个正常的c ++编译器,并且基本上是一个预处理器将cuda语法转换为可编译的东西。您可以看到它与 - verbose 标志一起使用的编译器。

nvcc is a wrapper around a normal c++ compiler, and is basically a preprocessor to convert the cuda syntax into something compilable. You can see what compiler it uses with the --verbose flag.

例如在我的机器编译



For instance on my machine compiling

// test.cpp
int main(){return 0;}

nvcc -v 给予

#$ _SPACE_= 
#$ _MODE_=DEVICE
#$ _HERE_=/usr/local/cuda/bin
#$ _THERE_=/usr/local/cuda/bin
#$ TOP=/usr/local/cuda/bin/..
#$ PATH=/usr/local/cuda/bin/../open64/bin:/usr/local/cuda/bin/../bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/Users/me/bin:/usr/local/aspell/bin:/usr/local/noweb:/usr/local/icon/bin:/usr/local/dmd/bin:/usr/local/cuda/bin:/usr/local/sed/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
#$ INCLUDES="-I/usr/local/cuda/bin/../include"  
#$ LIBRARIES=  "-L/usr/local/cuda/bin/../lib" -lcudart
#$ CUDAFE_FLAGS=
#$ OPENCC_FLAGS=
#$ PTXAS_FLAGS=
#$ gcc -c -x c++ "-I/usr/local/cuda/bin/../include"   -I. -m32 -malign-double -o "/tmp/tmpxft_000010af_00000000-1_test.o" "test.cpp" 
#$ g++ -m32 -malign-double -o "a.out" "/tmp/tmpxft_000010af_00000000-1_test.o"   "-L/usr/local/cuda/bin/../lib" -lcudart



>使用与此处列出的相同的编译器/标志应该为您提供二进制兼容性

Using the same compiler/flags as listed here should give you binary compatibility

这篇关于C ++异常二进制兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆