Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

How to check if library produces compile errors

DBaur
2017-02-10
2017-02-10
  • DBaur - 2017-02-10

    When a library is compiled by "Check all pool objects" from Build-menu and there occure build errors (which are displayed in die Build message window) it is nevertheless possible to save the library as "compiled library" - why?
    How can build/compile errors be detected in a python script if the "Check all pool objects" command is also triggered by python script?

    Thanks in advance.

     
  • mkeller - 2017-02-10

    Hi DBaur.

    DBaur hat geschrieben:
    When a library is compiled by "Check all pool objects" from Build-menu and there occure build errors (which are displayed in die Build message window) it is nevertheless possible to save the library as "compiled library" - why?
    How can build/compile errors be detected in a python script if the "Check all pool objects" command is also triggered by python script?

    Why don't you use the method of the project object?

    Here some example code which "builds" a loaded library and prints the compiler error:

    CompileCategory = Guid("{97F48D64-A2A3-4856-B640-75C046E37EA9}")
    \# Clear messages from Build category
    system.clear_messages(CompileCategory)
    projects.primary.check_all_pool_objects()
    \# Get message objects which contain all the data
    severities = {
    Β  Β Severity.FatalError : "Fatal error", Severity.Error : "Error",
    Β  Β Severity.Warning : "Warning", Severity.Information : "Information",
    Β  Β Severity.Text : "Text"
    Β  Β }
    msgs = system.get_message_objects(CompileCategory, Severity.FatalError|Severity.Error)
    for msg in msgs:
    Β  Β sev = severities[msg.severity]
    Β  Β print("{} {}{}: {}".format(sev, msg.prefix, msg.number, msg.text)
    

    BR
    Martin

     

Log in to post a comment.