- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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
最佳答案
我可以在 CUDA 5.0 中用我的 nvcc 重复你的错误。
看起来像是nvcc的bug。
pi_()()
在 g++ 中有效,但在 nvcc 中无效。
要让它在nvcc中工作,你必须这样写。
pi_ p;
std::cout<<p()<<std::endl;
在 nvcc 中使用 (pi_())()
时出现此错误。似乎 nvcc 错误地将 pi_ 视为类型转换。
a.cu(14): error: cast to type "pi_ ()" is not allowed
a.cu(14): error: expected an expression
2 errors detected in the compilation of "/tmp/tmpxft_00003006_00000000-6_a.cpp1.ii".
关于c++ - 为什么 nvcc 对仿函数不满意,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14360558/
在 Spring Boot 应用程序(v. 1.3.2)中,我尝试使用 jOOQ 生成所有映射数据库表的 POJO,以便它们也被注释为与 JPA 一起使用。数据库是 PostgreSQL。 问题在于
我有一些非常标准的代码,它从一个流中获取一个序列化对象,它基本上看起来像这样: Object getObjectFromStream(InputStream is) { ObjectInpu
在我的 Node.js 代码上运行 JSLint 时,它显示 “'Uint8Array' was used before it was defined 。” Mozilla reference将其置于
我在 Xcode6、beta 6 左右创建了一个项目(今天升级到 b7)。使用 Swift,一直在为 iOS 8 SDK 等开发。 到目前为止,Storyboard 有两个 View Controll
我是一名优秀的程序员,十分优秀!