整洁的C&x2B+;编译器错误Microsoft Visual Studio 2012 < P> >我想在微软Visual Studio 2012下运行以下C++库(2010):

整洁的C&x2B+;编译器错误Microsoft Visual Studio 2012 < P> >我想在微软Visual Studio 2012下运行以下C++库(2010):,c++,neat,C++,Neat,我已经修复了很多编译器错误,但是对于一些问题我没有找到解决方案。 编译器错误包括: 1>------ Build started: Project: My_Neuronal_Network, Configuration: Debug Win32 ------ 1> species.cpp 1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\species.cpp(454): warning C4101: '

我已经修复了很多编译器错误,但是对于一些问题我没有找到解决方案。 编译器错误包括:

1>------ Build started: Project: My_Neuronal_Network, Configuration: Debug Win32 ------
1>  species.cpp
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\species.cpp(454): warning C4101: 'spin' : unreferenced local variable
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\species.cpp(433): warning C4101: 'pause' : unreferenced local variable
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\species.cpp(453): warning C4101: 'marble' : unreferenced local variable
1>  population.cpp
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(71): warning C4101: 'count' : unreferenced local variable
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(432): warning C4101: 'pause' : unreferenced local variable
1>  genome.cpp
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1777): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1790): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1795): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1845): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1862): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1884): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1888): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1961): warning C4101: 'p1innov' : unreferenced local variable
1>  experiments.cpp
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(52): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(52): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(52): error C2133: 'evals' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(53): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(53): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(53): error C2133: 'genes' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(54): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(54): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(54): error C2133: 'nodes' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(316): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(316): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(316): error C2133: 'runs' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(512): error C3861: 'lrand48': identifier not found
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(513): error C3861: 'lrand48': identifier not found
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(514): error C3861: 'lrand48': identifier not found
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(515): error C3861: 'lrand48': identifier not found
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(573): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(575): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(580): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(581): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(623): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(623): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(623): error C2133: 'record' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(625): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(625): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(625): error C2133: 'genesrec' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(627): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(627): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(627): error C2133: 'nodesrec' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(629): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(629): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(629): error C2133: 'winnergens' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(692): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(706): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>  Generating Code...
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(543): error C4703: potentially uninitialized local pointer variable 'bias' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1948): error C4703: potentially uninitialized local pointer variable 'newgene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1533): error C4703: potentially uninitialized local pointer variable 'newnode' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1777): error C4703: potentially uninitialized local pointer variable 'nodep1' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1777): error C4703: potentially uninitialized local pointer variable 'nodep2' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1808): error C4703: potentially uninitialized local pointer variable 'newgene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1531): error C4703: potentially uninitialized local pointer variable 'newgene1' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1532): error C4703: potentially uninitialized local pointer variable 'newgene2' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(2500): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(2151): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(2794): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(90): error C4703: potentially uninitialized local pointer variable 'new_genome' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(289): error C4703: potentially uninitialized local pointer variable 'new_genome' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(546): error C4703: potentially uninitialized local pointer variable 'best_species' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\species.cpp(89): error C4703: potentially uninitialized local pointer variable 'thechamp' used
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
第一个错误发生在:

%experiments.cpp
 int evals[NEAT::num_runs];  //Hold records for each run 
所以这个值不是常数。如果我使用const int NEAT::num_runs=1,我什么也不会改变

是否有人已经使用了此库,并且能够在visual studio下运行此库

致意
Sebi

基本错误

error C4703: potentially uninitialized local pointer variable
只需使用NULL初始化变量,即可解决此错误。但实际上这并不是一个错误,而是一个警告,可能在项目设置中被关闭

genome.cpp、population.cpp、species.cpp中发生错误

所以C4703是唯一的错误 整洁实现的重要部分,这意味着它可以很容易地用Visual C++编写。 使用NEAT解决极点平衡任务时会出现其他错误。它们可能被当作用法的例子

是否有人已经使用了此库,并且能够在visual studio下运行此库

我已经提取了可以在其他VisualStudio项目中使用的从整洁到静态的链接库。解决方案中还有第二个项目作为使用niat.lib的示例

非基本错误

error C3861: 'lrand48': identifier not found
只需在VisualC++中使用rand()

error C2133: 'evals' : unknown size
int evals[niat::num_runs] >仅在VisualC++中使用此代码:<代码>::NUMYRUX < /COD> >代码> const 。编译器必须知道
num\u runs
的值


int*evalsPtr=newint[niat::num_runs]代码依赖于非标准的GCC扩展,VLAS在标准C++中是不合法的。重写它是不实际的,必须使用GCC。好的,谢谢,我现在使用GCC编译器的代码块。其中有些POSIX函数在Windows下不可用。我在Windows上有什么替代strdup()的方法?在Windows上,它看起来像是一个叫做_strdup()的函数,但编译器仍然说:“_strdup(..)没有在这个范围内声明”
RAND\u MAX
对于VC来说相当小,所以用
RAND()
代替
lrand48
可能不够。@Joey我同意你的看法。但在这个项目的范围内,
rand()
就足够了。在Windows、VisualC++中,有没有更好的替代代码“代码> LRAND48 <代码>?如果下一个代码> RANDMAX 不是问题,那么它应该是好的,但是一旦你需要一个大于32767的数字,那么我就不太情愿简单地推荐<代码> RAND()/<代码>作为替换。
error C2133: 'evals' : unknown size