在Visual Studio 2010中的C ++中使用lapack C标头错误 [英] errors using lapack C header in C++ with visual studio 2010

查看:388
本文介绍了在Visual Studio 2010中的C ++中使用lapack C标头错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我!我花了几个小时才能上网查找,但还没有找到解决方法....

Please help me! It takes me hours to look up in the internet and I haven't found a solution....

我正在尝试使用C++函数中的call lapack函数,但一开始我就失败了.这是我的代码:

I am trying to use the call lapack function from C++ functions but I failed at the very beginning. Here is my code:

#include "stdafx.h"
#include "targetver.h"
extern "C" {
#include "lapacke.h"
}


int main{}
{
    return 0;
}

我知道"lapacke.h"是C头,因此我使用extern "C"子句.但是,当我尝试编译这个琐碎的函数时,出现以下错误:

I know "lapacke.h" is a C header so I use the extern "C" clause. But while I try to compile this trivial function, I have the following error:

Error   1   error C2146: syntax error : missing ';' before identifier 'lapack_make_complex_float'   c:\users\svd_example1\example2\example2\lapacke.h   89  1   example2
Error   2   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\users\svd_example1\example2\example2\lapacke.h   89  1   example2

有人知道导致这些错误的原因吗?

Does anyone know what caused these errors?

非常感谢!

推荐答案

标头的相关部分是:

/* Complex types are structures equivalent to the
* Fortran complex types COMPLEX(4) and COMPLEX(8).
*
* One can also redefine the types with his own types
* for example by including in the code definitions like
*
* #define lapack_complex_float std::complex<float>
* #define lapack_complex_double std::complex<double>
*
* or define these types in the command line:
*
* -Dlapack_complex_float="std::complex<float>"
* -Dlapack_complex_double="std::complex<double>"
*/

/* Complex type (single precision) */
#ifndef lapack_complex_float
#include <complex.h>
#define lapack_complex_float    float _Complex
#endif

/* ... */    

lapack_complex_float lapack_make_complex_float( float re, float im );

这默认情况下使用C99 _Complex,Visual C ++不支持.您可以根据建议定义这些宏,以改为使用std::complex,而Visual C ++支持这些宏:

This uses C99 _Complex by default, which Visual C++ doesn't support. You can define those macros as suggested to use std::complex instead, which are supported by Visual C++:

#include <complex>
#define lapack_complex_float std::complex<float>
#define lapack_complex_double std::complex<double>
#include "lapacke.h"

这篇关于在Visual Studio 2010中的C ++中使用lapack C标头错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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