Advertisement

[v2.35.1] "No matching symbol" when using CompileGlobalVar()

Started by January 02, 2023 07:32 PM
2 comments, last by ohlidalp 1 year, 10 months ago

Hello.

I'm trying the following scenario:

  1. StartNewModule();
  2. CompileGlobalVar("Foo@ gFoo;");
  3. AddScriptSection(); with minimal script like `void main() { gFoo.bar(); }`
  4. BuildModule();

I receive build error Error = No matching symbol 'gFoo'

I tried using both single section/multiple sections, I tried changing order of the global var/script file and I tried calling Build() in between. The result is always the same. Did I miss anything? Of course I checked each single function return and the logfile written by the log callback, no indication of a problem. I was also running under Debug.

I encountered this while working on project https://github.com/RigsOfRods/rigs-of-rods​ which had successfully used AngelScript for years. All other systems function normally, there is already one running module at the time of trying this. For what it's worth, the code change is here: https://github.com/only-a-ptr/rigs-of-rods/commit/b62281b23f4a7a3bf3bc653060d25cfe1f3240a2​ .

I searched the internet and this forum, but got very little hits. I found and heeded https://www.gamedev.net/forums/topic/644188-angelscript-2263-global-property-issues-solved/5069638/​ but I don't think it's relevant here.

UPDATE: I tried to bypass our customized CScriptLoader and call AddScriptSection() directly with a test code snippet. Same result.

When asIScriptModule::Build is called it erases everything previously built in the module including what was compiled with CompileGlobalVar. That's why you get the "No matching symbol" error.

Instead of using the separate CompileGlobalVar call, add the global variable to the module with AddScriptSection. That way it will be compiled together with all the other script sections.

  1. StartNewModule();
  2. AddScriptSection("Foo@ gFoo;");
  3. AddScriptSection(); with minimal script like `void main() { gFoo.bar(); }`
  4. BuildModule();

Regards,

Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

@WitchLord That did what I needed, thank you! Consider this thread solved (I didn't find any method of renaming/marking the thread).

This topic is closed to new replies.

Advertisement