- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在我的 Mac 机器上编译 C++ 代码。我使用终端使用 python 运行安装文件。当我编译代码生成 .so 文件时,我收到以下错误:
python setup.py build
running build
running build_ext
building 'cec13_func' extension
gcc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -DNDEBUG -g -O3 -arch x86_64 -I/Applications/Canopy.app/appdata/canopy-1.5.4.3105.macosx-x86_64/Canopy.app/Contents/include/python2.7 -c cec13_func.cpp -o build/temp.macosx-10.6-x86_64-2.7/cec13_func.o
cec13_func.cpp:91:6: error: variable has incomplete type 'void'
void test_func(x, f, nx, mx, func_num);<br>
^
cec13_func.cpp:92:1: error: expected unqualified-id
{
^
2 errors generated.
error: command 'gcc' failed with exit status 1
代码如下:
double x[6]={1,2,3,4,5,6};
double f[2]={0,0};
int nx = 2;
int mx = 3;
int func_num = 1;
void test_func(x, f, nx, mx, func_num)
{
int cf_num=10,i;
if (ini_flag==1)
{
if ((n_flag!=nx)||(func_flag!=func_num))
{
ini_flag=0;
}
}
if (ini_flag==0)
{
FILE *fpt;
char FileName[30];
free(M);
free(OShift);
free(y);
free(z);
free(x_bound);
y=(double *)malloc(sizeof(double) * nx);
z=(double *)malloc(sizeof(double) * nx);
x_bound=(double *)malloc(sizeof(double) * nx);
for (i=0; i<nx; i++)
x_bound[i]=100.0;
sprintf(FileName, "input_data/M_D%d.txt", nx);
fpt = fopen(FileName,"r");
if (fpt==NULL)
{
printf("\n Error: Cannot open input file for reading \n");
}
M=(double*)malloc(cf_num*nx*nx*sizeof(double));
if (M==NULL)
printf("\nError: there is insufficient memory available!\n");
for (i=0; i<cf_num*nx*nx; i++)
{
fscanf(fpt,"%Lf",&M[i]);
}
fclose(fpt);
fpt=fopen("input_data/shift_data.txt","r");
if (fpt==NULL)
{
printf("\n Error: Cannot open input file for reading \n");
}
OShift=(double *)malloc(nx*cf_num*sizeof(double));
if (OShift==NULL)
printf("\nError: there is insufficient memory available!\n");
for(i=0;i<cf_num*nx;i++)
{
fscanf(fpt,"%Lf",&OShift[i]);
}
fclose(fpt);
n_flag=nx;
func_flag=func_num;
ini_flag=1;
//printf("Function has been initialized!\n");
}
for (i = 0; i < mx; i++)
{
switch(func_num)
{
case 1:
sphere_func(&x[i*nx],&f[i],nx,OShift,M,0);
f[i]+=-1400.0;
break;
case 2:
ellips_func(&x[i*nx],&f[i],nx,OShift,M,1);
f[i]+=-1300.0;
break;
default:
printf("\nError: There are only 28 test functions in this test suite!\n");
f[i] = 0.0;
break;
}
}
}
我需要一些建议。谢谢!
最佳答案
这...
void test_func(x, f, nx, mx, func_num)
...完全损坏:函数参数需要指定两者数据类型(例如int
、double
、const char*
) 和一个标识符。这些标识符的后续用法意味着它们是变量名,而不是 struct
/class
/union
/enum
或typedef
名称),因此缺少类型。
更令人困惑的是,文件顶部有:
double x[6]={1,2,3,4,5,6};
double f[2]={0,0};
int nx = 2;
int mx = 3;
int func_num = 1;
这些与 test_func
函数参数同名。也许您想将它们放在调用 test_func
的函数中,然后在调用期间传递它们?或者 - 更简单但不太灵活 - 如果 test_func
只需要使用这些特定参数运行,您可以将它们放在 test_func
主体的开头,并保留参数列表空(即 test_func()
)。
最后,您的文件扩展名是 .cpp
- 暗示 C++,但您的编译行使用的是用于 C 的 gcc
。代码本身看起来只使用了C++ 的 C 子集,但这并不意味着您不能使用 g++
编译它。
关于python - 错误 : variable has incomplete type 'void' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31106666/
for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=a"') do (
我在 Javascript 中有一组全局计数器变量: var counter_0 = 0; var counter_1 = 0; var counter_2 = 0; 等等 然后我有一个 Javasc
好的,我正在阅读一些有关 RedBlackTrees 的代码。我注意到这一行“v1 = v2 = v3 = v4;”我理解类似“v1 += v2”(将 v2 添加到 v1 的当前值)和“v1 = v2
我正在为 C# 中的游戏数据加载制作一个 csv 阅读器,我想做的就是从数组(变量)的值声明一个变量,我们可以在 php 中像 $$foo 那样做。喜欢 void csvReader(string s
假设我有变量 内容为“ 123 ”和变量 b123 里面有一些文字。出于某种原因,我想使用变量 作为第二个 var 名称的一部分。像这样的东西: SET a=123 SET b123=some_tex
我对 javascript 有点陌生,我无法通过谷歌搜索找到任何内容,我正在编写一个程序,并且能够执行我所要求的操作: if (Variable == 1 或 Variable == 2 或 Vari
我发现我自己在做这种类型的 IF 语句分配。例如: if($variable == 1 || $variable == "whatever" || $variable == '492') { ...
我的虚拟 PC 在 MS-DOS 6.22 上运行时出现问题。 我需要使用变量 Date ,但我无法得到它,因为每当我尝试回显变量时,它都会显示 %variable%反而。 我在 Windows 控制
尝试运行此代码时: List list = em.createQuery("select balance b from Users where b.userName = '" + user_name.
我有一些代码,其中变量可以是 undefined、null 或正常值。无论变量是 undefined 还是 null,代码都需要做同样的事情。说有没有危险 for (var cur = this.bu
我正在编写一个批处理命令脚本,其中检查环境变量。我需要通过传递所有必需的变量来编写一个 FOR 循环,然后验证它是否已定义,如果未定义,则提示该键的值并永久设置该变量。 问题是我无法取消引用循环变量并
我知道这些是 Rails 的基础知识,但我仍然不知道 = 符号和 => 之间的全部区别以及 @some_variable 之间的区别、@@some_variable 和 :some_variable
我正在使用以下内容创建一个动态变量(PHP 术语中的“变量变量”): foo: "test1" set to-word (rejoin [foo "_result_data"]) array 5 但是
我一直在啃 PHP 套接字服务器和客户端的基础知识 here . 然后我偶然发现了这些行(摘自上面链接的第一个示例,发生在 while 中): if (false === ($buf = socket
这个问题在这里已经有了答案: What does "|=" mean? (pipe equal operator) (6 个答案) 关闭 9 年前。 我正在寻找一些编码来扩展我在 Java 方面的知
如何在 C++ 中从其他变量的值打印变量我只是 C++ 的新手。 在 php 中,我们可以通过其他变量的值来制作/打印一个变量。像这样。 $example = 'foo'; $foo = 'abc';
作为 Ruby on Rails 新手,我明白“@”和“:”引用有不同的含义。我看到了this post在 SO 中,其中描述了一些差异。 @ 表示实例变量(例如@my_selection) :表示别
编程新手/甚至更新。一个小的 go 程序有问题 - 不会编译带有 undefined variable 错误。代码: package main import ( "fmt" "io" "o
我知道其他一些语言,如PHP,支持“变量变量名”的概念--即,字符串的内容可以用作变量名的一部分。。我听说总的来说这不是一个好主意,但我认为它可以解决我在Python代码中遇到的一些问题。。有没有可能
我有两个版本的代码。 版本 1 Launcher.java class Launcher { public static void main(String[] args) {
我是一名优秀的程序员,十分优秀!