NEAT C++ Visual Studio 2012 Microsoft编译器错误
NEAT C++ Compiler errors Microsoft Visual Studio 2012
我想在Visual Studio 2012下运行以下C++库(从2010年开始Microsoft):
http://nn.cs.utexas.edu/?neat-c
我已经修复了很多编译器错误,但对于某些问题,我找不到解决方案。编译器错误为:
1>------ Build started: Project: My_Neuronal_Network, Configuration: Debug Win32 ------
1> species.cpp
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1species.cpp(454): warning C4101: 'spin' : unreferenced local variable
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1species.cpp(433): warning C4101: 'pause' : unreferenced local variable
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1species.cpp(453): warning C4101: 'marble' : unreferenced local variable
1> population.cpp
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(71): warning C4101: 'count' : unreferenced local variable
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(432): warning C4101: 'pause' : unreferenced local variable
1> genome.cpp
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1777): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1790): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1795): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1845): warning C4018: '<' : signed/unsigned mismatch
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1862): warning C4018: '<' : signed/unsigned mismatch
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1884): warning C4018: '<' : signed/unsigned mismatch
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1888): warning C4018: '<' : signed/unsigned mismatch
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1961): warning C4101: 'p1innov' : unreferenced local variable
1> experiments.cpp
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(52): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(52): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(52): error C2133: 'evals' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(53): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(53): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(53): error C2133: 'genes' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(54): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(54): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(54): error C2133: 'nodes' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(316): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(316): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(316): error C2133: 'runs' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(512): error C3861: 'lrand48': identifier not found
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(513): error C3861: 'lrand48': identifier not found
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(514): error C3861: 'lrand48': identifier not found
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(515): error C3861: 'lrand48': identifier not found
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(573): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(575): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(580): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(581): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(623): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(623): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(623): error C2133: 'record' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(625): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(625): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(625): error C2133: 'genesrec' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(627): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(627): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(627): error C2133: 'nodesrec' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(629): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(629): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(629): error C2133: 'winnergens' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(692): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(706): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1> Generating Code...
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(543): error C4703: potentially uninitialized local pointer variable 'bias' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1948): error C4703: potentially uninitialized local pointer variable 'newgene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1533): error C4703: potentially uninitialized local pointer variable 'newnode' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1777): error C4703: potentially uninitialized local pointer variable 'nodep1' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1777): error C4703: potentially uninitialized local pointer variable 'nodep2' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1808): error C4703: potentially uninitialized local pointer variable 'newgene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1531): error C4703: potentially uninitialized local pointer variable 'newgene1' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1532): error C4703: potentially uninitialized local pointer variable 'newgene2' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(2500): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(2151): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(2794): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(90): error C4703: potentially uninitialized local pointer variable 'new_genome' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(289): error C4703: potentially uninitialized local pointer variable 'new_genome' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(546): error C4703: potentially uninitialized local pointer variable 'best_species' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1species.cpp(89): error C4703: potentially uninitialized local pointer variable 'thechamp' used
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
整齐地.cpp定义了以下内容:
%neat.cpp
...
int NEAT::num_runs = 1;
...
第一个错误发生在:
%experiments.cpp
int evals[NEAT::num_runs]; //Hold records for each run
所以不知何故,这个值不是恒定的。如果我使用 const int NEAT::num_runs=1,我什么都不会改变;
是否有人已经使用过这个库并能够在可视化工作室下运行它?
此致敬意塞比
基本错误
error C4703: potentially uninitialized local pointer variable
此错误仅通过使用 NULL 初始化变量来解决。但实际上这不是错误,它是警告,可能会在项目设置中关闭。
genome.cpp, population.cpp, species.cpp
中发生错误
所以 C4703 只是错误NEAT 实现的重要组成部分,这意味着它可以很容易地用 Visual C++ 编译。
在使用NEAT解决极平衡任务时会发生其他错误。它们可以被视为使用NEAT的示例。
是否有人已经使用过这个库并能够在可视化工作室下运行它?
我已经将NEAT提取到静态链接库,该库可用于其他Visual Studio项目。解决方案中还有第二个项目作为使用 NEAT.lib 的示例
你可以在这里查看我的解决方案
非本质错误
error C3861: 'lrand48': identifier not found
只需在 VisualC++ 中使用 rand()。
error C2133: 'evals' : unknown size
int evals[NEAT::num_runs];
- 只有在const
NEAT::num_runs
时,才能在 Visual C++ 中使用它。编译器必须知道num_runs
的值。
int *evalsPtr = new int[NEAT::num_runs];
- 在其他情况下使用此
- 与其他编译器相比,相同的代码在工作室Microsoft提供不同的输出
- C++正则表达式失败(GCC vs Microsoft 编译器)
- 为什么这C++只在编译器上编码一个不明确的方法调用Microsoft?
- 如何使用Microsoft Visual Studio 2017配置外部编译器,如gcc +14
- 带有Eclipse的Microsoft Visual C++Build Tools编译器
- 具有状态的Microsoft编译器版本19.16.27024.1的问题
- 使用Microsoft编译器生成 CMOV 指令
- Docker中的Microsoft编译器
- 我应该在Qt创建者中更改什么,以便使用MinGW而不是microsoft编译器进行编译
- NEAT C++ Visual Studio 2012 Microsoft编译器错误
- Microsoft C++编译器有一个错误
- Microsoft Python 2.7..编译器无法下载,我应该使用什么更高版本?
- visual MSVC编译器错误C2688:Microsoft C++ABI角大小写问题
- 模板类中的尾随返回类型(GNU和Microsoft编译器之间的矛盾)
- 在Windows 7中通过GnuWin32使用Microsoft Visual C/C++编译器编译源(.C)文件时出错
- visual Microsoft C++编译器:如何使用/O2禁用自动矢量化
- 在 G++ 中">"之前但在 Microsoft 编译器中不的预期主表达式
- 使用Microsoft c++编译器,无需安装Visual Studio
- 如何在没有IDE的情况下使用Microsoft c++编译器编译c++库
- 无法使用Microsoft编译器编译Qt