整合提升与数字配方3代码
integrating boost with numerical recipes 3 code
当我同时使用nr3.h和boost库时,我会得到一堆错误。
我使用ubuntu 10.04与libboost1.40和代码从http://www.nr.com/(第三版)
try.cc:
#include "nr3.h"
#include <boost/algorithm/string/predicate.hpp>
int main(void) {
return 0;
}
我编译代码"g++ try."Cc",我得到了错误。如果我注释掉nr3.h行或者<提高……>行,代码编译得很好。
错误如下:
In file included from /usr/include/boost/assert.hpp:36,
from /usr/include/boost/range/iterator_range.hpp:31,
from /usr/include/boost/range/as_literal.hpp:22,
from /usr/include/boost/algorithm/string/predicate.hpp:19,
from boostnrexample.cc:2:
/usr/include/assert.h: In function ‘void __assert_fail(const char*, const char*, unsigned int, const char*)’:
/usr/include/assert.h:73: error: expected primary-expression before ‘,’ token
/usr/include/assert.h: At global scope:
/usr/include/assert.h:73: error: declaration does not declare anything
/usr/include/assert.h: In function ‘void __assert_perror_fail(int, const char*, unsigned int, const char*)’:
/usr/include/assert.h:79: error: expected primary-expression before ‘,’ token
/usr/include/assert.h: At global scope:
/usr/include/assert.h:79: error: declaration does not declare anything
/usr/include/assert.h: In function ‘void __assert(const char*, const char*, int)’:
/usr/include/assert.h:85: error: expected primary-expression before ‘,’ token
/usr/include/assert.h: At global scope:
/usr/include/assert.h:85: error: declaration does not declare anything
In file included from /usr/include/c++/4.4/x86_64-linux-gnu/bits/messages_members.h:37,
from /usr/include/c++/4.4/bits/locale_facets_nonio.h:1905,
from /usr/include/c++/4.4/locale:43,
from /usr/include/boost/algorithm/string/compare.hpp:15,
from /usr/include/boost/algorithm/string/predicate.hpp:22,
from boostnrexample.cc:2:
/usr/include/libintl.h: In function ‘char* gettext(const char*)’:
/usr/include/libintl.h:41: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: At global scope:
/usr/include/libintl.h:41: error: declaration does not declare anything
/usr/include/libintl.h: In function ‘char* dgettext(const char*, const char*)’:
/usr/include/libintl.h:46: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: At global scope:
/usr/include/libintl.h:46: error: declaration does not declare anything
/usr/include/libintl.h: In function ‘char* __dgettext(const char*, const char*)’:
/usr/include/libintl.h:48: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: At global scope:
/usr/include/libintl.h:48: error: declaration does not declare anything
/usr/include/libintl.h: In function ‘char* dcgettext(const char*, const char*, int)’:
/usr/include/libintl.h:54: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: At global scope:
/usr/include/libintl.h:54: error: declaration does not declare anything
/usr/include/libintl.h: In function ‘char* __dcgettext(const char*, const char*, int)’:
/usr/include/libintl.h:57: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: At global scope:
/usr/include/libintl.h:57: error: declaration does not declare anything
/usr/include/libintl.h: In function ‘char* ngettext(const char*, const char*, long unsigned int)’:
/usr/include/libintl.h:64: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: At global scope:
/usr/include/libintl.h:64: error: declaration does not declare anything
/usr/include/libintl.h: In function ‘char* dngettext(const char*, const char*, const char*, long unsigned int)’:
/usr/include/libintl.h:70: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: At global scope:
/usr/include/libintl.h:70: error: declaration does not declare anything
/usr/include/libintl.h: In function ‘char* dcngettext(const char*, const char*, const char*, long unsigned int, int)’:
/usr/include/libintl.h:77: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: At global scope:
/usr/include/libintl.h:77: error: declaration does not declare anything
/usr/include/libintl.h: In function ‘char* textdomain(const char*)’:
/usr/include/libintl.h:83: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: In function ‘char* bindtextdomain(const char*, const char*)’:
/usr/include/libintl.h:88: error: expected primary-expression before ‘,’ token
/usr/include/libintl.h: In function ‘char* bind_textdomain_codeset(const char*, const char*)’:
/usr/include/libintl.h:93: error: expected primary-expression before ‘,’ token
更新:我还在nr.com论坛(http://www.nr.com/forum/showthread.php?t=2148)上发表了这篇文章。并得到了一个响应,问题是nr3.h为throw()做了一个定义宏。我仍然不确定什么是一个强大的解决方案。
一个快速的修复方法是进入nr3.h并将c++关键字滥用宏"throw"更改为一个无害的无c++关键字,如"toss"。
相关文章:
- 如何修复我的最大公约数代码?它适用于除零和零以外的所有数字
- 如何优化代码以返回最接近给定整数的数字,但给定列表中不存在?
- 在使用堆栈为下一个最大数字编写代码时面临 SIGSEGV(分段错误)
- 无法理解代码背后的逻辑,这是在两个给定数字之间生成素数的优化问题
- 有人可以解释我这个代码吗?它给出与我们输入的数字相反
- 我怎么不能按课程代码的降序对数字进行排序
- 为什么当我在 c++ 中运行函数时,我的代码显示数字 53
- 代码以查找数组中的最大数字,但它仅将第一个数字显示为最大数字. 有人请告诉我为什么
- 为什么这个代码不适用于大数字
- 我如何在一个 if 语句中声明所有数字我尝试通过其他方式声明所有数字,如果一个接一个,但似乎代码有逻辑错误
- 下面的代码是如何工作的?它输出分解的数字并且功能齐全,我只是不明白它是如何做到的
- Cpp代码故障(显示意外数字)
- 如何让我的代码显示文件名不正确或文件中数字的平均值?
- 试图找到一个数字的平方根,但代码不起作用。C++
- 我的代码应该接受一个数字,并返回字母等级或"Grade is not valid"但 else 语句不起作用
- 输入的数字与代码显示的数字不同,在结构中使用数组,为什么?
- 我的代码似乎在查找最大数字时存在语法错误
- 此代码如何计算数字的奇偶校验?
- Fibbonaci 递归代码返回错误值,始终返回下一个数字
- 我在此代码中要求一个数字,如果用户给出一个字母,我该怎么办?