在premake.lua中尝试索引一个空值。

huangapple go评论99阅读模式
英文:

Attempt to index a nil value in premake.lua

问题

我已经为我的C++游戏引擎创建了一个premake.lua文件。但当我运行 premake5.exe vs2017 时,我收到以下错误信息:
Game Engine/premake5.lua:35: 尝试索引一个空值
如果我转到第35行,它抱怨如下:

  1. 34 filter "system:windows":
  2. 35 cppdialect "C++17"
  3. 36 staticruntime "On"
  4. 37 systemversion "latest"

我发现,如果我注释掉第34行,似乎可以工作,但然后在第49行上出现相同的错误:

  1. 49 filter "configurations:Debug":
  2. 50 defines "BZ_DEBUG"
  3. 51 symbols "On"

如果我尝试注释掉所有我的筛选字段,我会收到以下错误信息:
Error: [string "return cfg-architecture"]:1: 尝试在一个表值上执行算术运算(全局 'cfg'),在标记: cfg-architecture

我尝试了多个版本的premake,也尝试了使用不同的VS版本编译,但每次都得到相同的结果。

英文:

I have made a premake.lua file for mye C++ Game Engine. But when i run premake5.exe vs2017 i get the error:
Game Engine/premake5.lua:35: attempt to index a nil value
if i go to line 35 where it complaines i see this:

  1. 34 filter "system:windows":
  2. 35 cppdialect "C++17"
  3. 36 staticruntime "On"
  4. 37 systemversion "latest"

i found out that if i comment out line 34 it seems to work but then proceedes to giving the same error on line 49:

  1. 49 filter "configurations:Debug":
  2. 50 defines "BZ_DEBUG"
  3. 51 symbols "On"

if i at try to comment out all my filter fields. i get this error:
Error: [string "return cfg-architecture"]:1: attempt to perform arithmetic on a table value (global 'cfg') in token: cfg-architecture

i have tried multiple versions of premake and have tried to compile multiple with different vs versions. But i get the same result every time.

答案1

得分: 2

你在 filter 中的字符串后面多了一个 :,所以你尝试调用 "some_string":cppdialect("C++17"),但字符串没有这个方法。

你的代码应该是:

  1. filter "system:windows"
  2. cppdialect "C++17"
  3. staticruntime "On"
  4. systemversion "latest"
英文:

You have extra : after your string in filter. so you try to call "some_string":cppdialect("C++17") and string doesn't have that method.

Your code should be

  1. filter "system:windows"
  2. cppdialect "C++17"
  3. staticruntime "On"
  4. systemversion "latest"

huangapple
  • 本文由 发表于 2023年7月13日 22:15:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680382.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定