【发布时间】:2015-12-01 04:35:34
【问题描述】:
我正在开发 MINIX 3。我更改了进程调度程序,现在我想在那里进行一些测试。
问题是当我想使用double 时出现错误。有趣的是,如果我在类的全局中声明并初始化double variable,它不会显示错误,但是当我想在方法中使用相同的double variable,并尝试编译MINIX 3(版本 3.1.6) 我收到此错误:
/usr/lib/em_led: /usr/lib/i386/libc.a(exit.o): multiply defined (error)
Undefined:
_test_variable (<---- the name of the variable is "test_variable")
make in /usr/src/kernel: Exit code 1
make in /usr/src/tools: Exit code 1
make: made 'image' look old
当我在/usr/src/tools 中使用命令make hdboot 时会发生这种情况,我在make install 之后使用该命令
有人知道这里的问题是什么吗?
已编辑
代码是:
FORWARD _PROTOTYPE( struct proc * pick_proc, (void));
FORWARD _PROTOTYPE( void enqueue_head, (struct proc *rp));
double test_variable;
//(the Variable **test_variable** one is Declared on TOP of the class after the Includes and after the declarations of the Methods
PRIVATE struct proc * pick_proc(void)
{
register struct proc *rp; /* process to run */
int q; /* iterate over queues */
int proceset;
proc_nr_t proci;
if (first_time == 1)
{
test_variable = 6.5;
}
【问题讨论】:
-
您显示了两个相互冲突的错误:
multiply defined (error)和Undefined: _test_variable。这些都不是指variable。所以,你需要展示你的代码——你认为你定义了test_variable,然后担心为什么你会同时遇到多个定义的问题。编译器通常会在变量名中添加前导下划线。 -
@JonathanLeffler,我编辑了我的帖子。请看代码
-
你给出了
test_variable的暂定定义;这通常就足够了。您可以考虑使用double test_variable = 6.5;,这甚至可能意味着您无需使用first_time变量——其定义也未显示。 -
这只是为了测试
first_time,因为pick_proc是从每个进程中调用的。所以我只想初始化一次。如上所述的问题是我无法在方法内部进行初始化......我需要在方法内部进行初始化。我不想要一个具有相同值的 STATIC 变量,我需要改变和操纵这个变量的值 -
好的。对不起,我不能再帮忙了。我在 Minix 上的工作还不够多,没有什么好主意。你在做的事情看起来或多或少是 kosher,我不知道出了什么问题。
标签: c compiler-errors operating-system minix