hc.cu的代码:
//patch for g++4.7
#ifdef _GLIBCXX_ATOMIC_BUILTINS
#undef _GLIBCXX_ATOMIC_BUILTINS
#endif
#ifdef _GLIBCXX_USE_INT128
#undef _GLIBCXX_USE_INT128
#endif
struct pi_
{
double operator()() const
{
return 3.141592653589793;
}
};
#include <iostream>
int main()
{
std::cout << pi_()();
return 0;
}
编译将导致两个(不是一个)错误:
$nvcc -c hc.cu
hc.cu: In function ‘int main()’:
hc.cu:21:22: error: ‘type name’ declared as function returning a function
hc.cu:21:22: error: ‘type name’ declared as function returning a function
有人可以告诉我问题吗?我是使用 g++ 4.7 的 archlinux 用户,我必须取消定义两个宏才能使 nvcc 工作;这两个undefs在编译错误中起到了一些作用吗?
关于cuda的一些信息:
$ pacman -Qi cuda
Name : cuda
Version : 5.0.35-3
URL : http://www.nvidia.com/object/cuda_home.html
Licenses : custom
Groups : None
Provides : cuda-toolkit cuda-sdk
Depends On : gcc-libs opencl-nvidia
Optional Deps : gdb: for cuda-gdb
Required By : cuda-z cula cusp
Conflicts With : None
Replaces : cuda-toolkit cuda-sdk
Installed Size : 1464880.00 KiB
Packager : Sven-Hendrik Haase <sh@lutzhaase.com>
Architecture : x86_64
Build Date : Tue 30 Oct 2012 12:51:49 PM CET
Install Date : Wed 09 Jan 2013 02:38:26 PM CET
Install Reason : Explicitly installed
Install Script : Yes
Description : NVIDIA's GPU programming toolkit
和 g++
pacman -Qi gcc-multilib
Name : gcc-multilib
Version : 4.7.2-3
URL : http://gcc.gnu.org
Licenses : GPL LGPL FDL custom
Groups : multilib-devel
Provides : gcc=4.7.2-3
Depends On : gcc-libs-multilib=4.7.2-3 binutils-multilib>=2.23 libmpc cloog ppl
Optional Deps : None
Required By : boost-build chicken clang dkms gcc-fortran-multilib gcc-objc-multilib ghc htmldoc libreoffice-sdk libtool virtualbox-host-dkms
Conflicts With : gcc
Replaces : None
Installed Size : 81560.00 KiB
Packager : Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Architecture : x86_64
Build Date : Wed 26 Dec 2012 01:22:52 PM CET
Install Date : Mon 31 Dec 2012 03:40:26 PM CET
Install Reason : Installed as a dependency for another package
Install Script : Yes
Description : The GNU Compiler Collection - C and C++ frontends for multilib