CUDA(5.5)与MySQL 5.6的rint函数定义冲突引起的VS编译器C2264错误
向CUDA project中添加了如下的包含目录后:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include;
..\include_p;
..\include_p\gdal;
..\include_p\mysql;
..\include;
..\include_cg;
$(IncludePath)
在main.cu中添加如下包含文件:
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <cuda_device_runtime_api.h> #include "cuda_helloworld_kernel.cu"
#include "host_rapc_cuda.cu"
而host_rapc_cuda.cu文件又包含了:
#include "gt_geometry.h"
#include "phd_rapc_vtx.h"//该文件包含了gt_datasource.h文件,后者又包含了mysql_global.h文件,与CUDA的math_functions.h中定义的相同名称的rint函数引起了冲突
#include "gt_geometryoverlay_phdpaper.h"
编译项目,出现下面的症状:
错误 433 error C2264: “rint”: 函数定义或声明中有错误;未调用函数 c:\program files\nvidia gpu computing toolkit\cuda\v5.5\include\math_functions.h 11639

分析:
CUDA的rint函数定义在math_functions.h中,实现如下:
static __inline__ __host__ __device__ float rint(float a)
{
return rintf(a);
}
mysql的rint的函数定义在my_global.h中,实现如下:
#ifndef HAVE_RINT
/**
All integers up to this number can be represented exactly as double precision
values (DBL_MANT_DIG == 53 for IEEE 754 hardware).
*/
#define MAX_EXACT_INTEGER ((1LL << DBL_MANT_DIG) - 1) /**
rint(3) implementation for platforms that do not have it.
Always rounds to the nearest integer with ties being rounded to the nearest
even integer to mimic glibc's rint() behavior in the "round-to-nearest"
FPU mode. Hardware-specific optimizations are possible (frndint on x86).
Unlike this implementation, hardware will also honor the FPU rounding mode.
*/ static inline double rint(double x)
{
double f, i;
f = modf(x, &i); /*
All doubles with absolute values > MAX_EXACT_INTEGER are even anyway,
no need to check it.
*/
if (x > 0.0)
i += (double) ((f > 0.5) || (f == 0.5 &&
i <= (double) MAX_EXACT_INTEGER &&
(longlong) i % ));
else
i -= (double) ((f < -0.5) || (f == -0.5 &&
i >= (double) -MAX_EXACT_INTEGER &&
(longlong) i % ));
return i;
}
#endif /* HAVE_RINT */
由此可见,mysql和CUDA中对rint函数的重复定义在编译时引起了混淆,而mysql中的rint函数可以通过定义HAVE_RINT宏进行控制,我们在gts_cg_port.h头文件中添加定义:
#define HAVE_RINT 1
重新编译gtcg库后,再重新编译我们的CUDA工程,错误消失,编译成功。
CUDA(5.5)与MySQL 5.6的rint函数定义冲突引起的VS编译器C2264错误的更多相关文章
- MySQL 日期、时间转换函数
MySQL 日期.时间转换函数:date_format(date,format), time_format(time,format) 能够把一个日期/时间转换成各种各样的字符串格式.它是 str_to ...
- mysql中bit_count和bit_or函数的含义
翻阅mysql手册时,看到有个示例使用了bit_or方法来去除重复的数据,一开始没看明白,后来看明白之后感觉非常巧妙.示例要实现的功能就是计算每月有几天有访问,先把示例摘录在这里. 1 2 3 4 5 ...
- 在MySQL向表中插入中文时,出现:incorrect string value 错误
在MySQL向表中插入中文时,出现:incorrect string value 错误,是由于字符集不支持中文.解决办法是将字符集改为GBK,或UTF-8. 一.修改数据库的默认字符集 ...
- MySQL 获得当前日期时间\时间戳 函数 ( 转自传智播客)
MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +-------+ | now() | +-- ...
- mysql中You can’t specify target table for update in FROM clause错误解决方法
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...
- mysql中的去除空格函数
(1)mysql replace 函数 语法:replace(object,search,replace) 意思:把object中出现search的全部替换为replace 案例:update `ne ...
- mysql 中时间和日期函数应用
一.MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +-------------------- ...
- MySqL触发器以及常用转换函数注意事项
1,触发器(http://www.cnblogs.com/zzwlovegfj/archive/2012/07/04/2576989.html) 1.MYSQL中触发器中不能对本表进行 i ...
- MySql 学习之路-Date函数
MySQL中重要的内建函数 函数 描述 NOW() 返回当前的日期和时间 NOW() 返回当前的日期和时间. 语法 NOW() -- 实例 -- 下面是 SELECT 语句: SELECT NOW() ...
随机推荐
- 集合框架_DAY15
1:集合(掌握) (1)集合的由来 我们需要对多个对象进行存储和获取.可以使用对象数组.但是,如果对象的个数是变化的,对象数组就解决不了了.怎么办呢?java就提供了集合类解决. (2)集合和数组的区 ...
- (转)python协程2:yield from 从入门到精通
原文:http://blog.gusibi.com/post/python-coroutine-yield-from/ https://mp.weixin.qq.com/s?__biz=MzAwNjI ...
- sftp命令不被识别
sftp命令不被识别 原因:C:\Windows\System32文件夹下面没有sftp可执行程序 解决方案:安装openssh,安装完成之后可发现在path系统变量的值中多了openssh的安装目录 ...
- vue.js过渡效果之--javascript钩子
写在前面 姊妹篇 vue.js之过渡效果-css.今天一篇博文阅读量破300,心里还是有点小激动的.没错,我就是这么容易满足(害羞).这个数据可能连大牛一篇文章阅读量的零头都没有,但这却是我个人的一 ...
- CFileDialog类的详情
CFileDialog类封装了Windows常用的文件对话框. 常用的文件对话框提供了一种简单的与Windows标准相一致的文件打开和文件存盘对话框功能. void CnotepadDlg::OnOp ...
- Chapter 2 Open Book——25
"My name is Edward Cullen," he continued. "I didn't have a chance to introduce myself ...
- spring boot 自动更新静态文件和后台代码 -- 热部署
在spring boot使用的过程中, 发现我修改了静态文件, 前台刷新后, 没有任何变化, 必须重新启动, 才能看到, 这简直不能让人接受. 那有什么方法来解决这个问题呢. Baidu之后, 得到了 ...
- map集合的见解、排序
map是键值对的集合接口,它的实现类主要包括:HashMap,TreeMap,Hashtable以及LinkedHashMap等 HashMap:我们最常用的Map,它根据key的HashCode 值 ...
- Restful API 设计参考原则
在项目中,需要为后台服务撰写API.刚开始接触的时候,并没有考虑太多,就想提供URL,服务端通过该URL进行查询.创建.更新等操作即可.但再对相关规范进行了解后,才发现,API的设计并没有那么简单,远 ...
- 【一个小功能】从js判断ie版本,浅谈navigator对象的appName属性
判断IE版本主要的是获取两个属性,a.当前浏览器名称,b.当前浏览器版本,为此不得不了解navigator对象. 先贴代码 window.onload = function() { var brows ...