我最近设法构建并运行一个简单的CLAPACK Microsoft Visual Studio 2008项目(从http://icl.cs.utk.edu/lapack-for-windows/lapack/index.html下载)。之后,在LAPACK dgesv_调用之后插入一行以初始化另一个整数tempInteger会导致构建失败。错误是:CLAPACK-EXAMPLE.c(30):错误C2143:语法错误:缺少';'在'类型'之前。似乎执行LAPACK功能会阻止某些操作,例如之后的变量初始化。谁能帮我理解发生了什么并修复它?提前致谢。代码清单如下:
#include < stdio.h>
#include "f2c.h"
#include "clapack.h"
int main(void)
{
/* 3x3 matrix A
* 76 25 11
* 27 89 51
* 18 60 32
*/
double A[9] = {76, 27, 18, 25, 89, 60, 11, 51, 32};
double b[3] = {10, 7, 43};
int N = 3;
int nrhs = 1;
int lda = 3;
int ipiv[3];
int ldb = 3;
int info;
int qqq = 1;
dgesv_(&N, &nrhs, A, &lda, ipiv, b, &ldb, &info);
if(info == 0) /* succeed */
printf("The solution is %lf %lf %lf\n", b[0], b[1], b[2]);
else
fprintf(stderr, "dgesv_ fails %d\n", info);
int tempInteger = 1;
return info;
}
答案 0 :(得分:0)
如果此文件编译为C文件而不是C ++文件,则应在函数顶部声明tempInteger
类型。
例如:
#include < stdio.h>
#include "f2c.h"
#include "clapack.h"
int main(void)
{
/* 3x3 matrix A
* 76 25 11
* 27 89 51
* 18 60 32
*/
double A[9] = {76, 27, 18, 25, 89, 60, 11, 51, 32};
double b[3] = {10, 7, 43};
int N = 3;
int nrhs = 1;
int lda = 3;
int ipiv[3];
int ldb = 3;
int info;
int qqq = 1;
int tempInteger;
dgesv_(&N, &nrhs, A, &lda, ipiv, b, &ldb, &info);
if(info == 0) /* succeed */
printf("The solution is %lf %lf %lf\n", b[0], b[1], b[2]);
else
fprintf(stderr, "dgesv_ fails %d\n", info);
tempInteger = 1;
return info;
}