TCC67 compiler output messages

Moderators: TomKerekes, dynomotion

Post Reply
SamMarrocco
Posts: 51
Joined: Fri Apr 27, 2018 12:44 pm

TCC67 compiler output messages

Post by SamMarrocco » Sat Dec 26, 2020 2:49 pm

When using the coff compiler method in dotnet, is there a method of obtaining the error message specifics? The result variable contains a generic "failed to compile" message but never the specifics of the error such as are given by the KMotion CCode module.

User avatar
TomKerekes
Posts: 1515
Joined: Mon Dec 04, 2017 1:49 am

Re: TCC67 compiler output messages

Post by TomKerekes » Sat Dec 26, 2020 9:11 pm

Hi Sam,

That seems to be a bug. Code that was intending to check for a valid null terminated string from the Compiler and if not valid returned a generic Compile Error was faulty. As a null will never be found in a string as valid string characters are before any null.

In C:\KMotionSrc\KMotion_dotNet\DM Controller\KM_Controller.cs this code:

Code: Select all

                    int result=KM_dotnet_Interop_CompileAndLoadCoff(_InstanceHandle, thread, programname, ref error, _ErrorLength);
                    if (result!=0 && (error=="" || !error.Contains((char)0))) error="Error Compiling and Loading Program";
Should be:

Code: Select all

                    // error string may not be null terminated if error was longer then _ErrorLength.
                    // In this case it will have a longer length (including spaces) so terminate it 
                    if (error.Length >= _ErrorLength) error = error.Substring(0, _ErrorLength - 1);
                    if (result!=0 && error=="") error="Error Compiling and Loading Program";
Also attached is the corrected source file. Otherwise you might use Compile() instead. It should return a detailed error. There is also a minor error with it where extra spaces at the end are added whenever the error message length is over the limit. This is also corrected in the attached file.

HTH
Attachments
KM_Controller.cs
(73.17 KiB) Downloaded 8 times
Regards,

Tom Kerekes
Dynomotion, Inc.

SamMarrocco
Posts: 51
Joined: Fri Apr 27, 2018 12:44 pm

Re: TCC67 compiler output messages

Post by SamMarrocco » Fri Jan 01, 2021 9:33 pm

Well, I gave it a shot, but even after finding the proper Windows SDK for the KMotion compiles, I'd need to add too many "vs 2015" things to my development machine to get that recompile to work with the fix you attached. I recall having a lot of issue moving from 2015 to 2019 vs.net at one point and am going to avoid backtracking at this point. It didn't seem like I could 'pull' everything forward to 2019 easily either.

I appreciate your finding/fixing the bug, but I think I'll wait to implement until the next release of KMotion that incorporates it as a fix. It wasn't urgent, just frustrating while debugging C-Code from my app.

Thanks!

Post Reply