Acknowledged

bug: compilation fails because of code inside removed has block

I get a compilation error:

ERROR: fenix5: AppView.mc:38,4: Could not find method onTimerEvent on object $.AppView

I don't think I am supposed to get. SDK: 7.4.3, device: fenix5 that doesn't support ActivityRecording.Session.setTimerEventListener , and this is my relevant part of the code:

(Sorry for the unformatted code, can't post code! see: https://forums.garmin.com/developer/connect-iq/f/discussion/389914/meta-forum-returning-lots-of-errors-today-e-g-parens-links-and-images-cause-problems )

and monkey.jungle:

project.optimization = 3z
fenix5.excludeAnnotations=$(fenix5.excludeAnnotations);session_timer_event_listener
When I remove the (:session_timer_event_listener) then it compiles, but why do I need to have an empty function just to be able to compile something that can be never called?
Note that the block for the has is correctly removed ("never called is not logged"). This is my command line for compilation:
java -Xms1g -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar ~/Library/Application Support/Garmin/ConnectIQ/Sdks/connectiq-sdk-mac-7.4.3-2024-12-11-90ec25e45/bin/monkeybrains.jar -o bin/App.prg -f App/monkey.jungle -y garmin/garmin_developer_key.der -d fenix5_sim -w
Parents
  • > Note that the block for the has is correctly removed ("never called is not logged")

    That doesn't prove that that the if-block for the has check was removed at compile-time, that only proves that the condition is false (either at compile-time or run-time) and the corresponding code is never run (whether that decision was made at compile-time or run-time).

    Having said that, as a test I modified your code as follows:

    //  if (ActivityRecording.Session has :setTimerEventListener) {
        if (false) {
    This modification removes any question about whether api has checks are being removed at compile-time or not. (Recall a recent forum post which found that enduro3 was not yet removing api has checks at compile time - a member of the CIQ team said that the device config needed to be updated).
    I built the resulting code with "-O 3" optimization, and I still receive the following error: Could not find method onTimerEvent on object $.TestAppView

    I can think of two possibilities:

    - if-blocks are not being removed at compile time in this case

    - if-blocks are being removed at compile time, but too late to avoid an error about being unable to find a symbol that's called within a removed if-block

Comment
  • > Note that the block for the has is correctly removed ("never called is not logged")

    That doesn't prove that that the if-block for the has check was removed at compile-time, that only proves that the condition is false (either at compile-time or run-time) and the corresponding code is never run (whether that decision was made at compile-time or run-time).

    Having said that, as a test I modified your code as follows:

    //  if (ActivityRecording.Session has :setTimerEventListener) {
        if (false) {
    This modification removes any question about whether api has checks are being removed at compile-time or not. (Recall a recent forum post which found that enduro3 was not yet removing api has checks at compile time - a member of the CIQ team said that the device config needed to be updated).
    I built the resulting code with "-O 3" optimization, and I still receive the following error: Could not find method onTimerEvent on object $.TestAppView

    I can think of two possibilities:

    - if-blocks are not being removed at compile time in this case

    - if-blocks are being removed at compile time, but too late to avoid an error about being unable to find a symbol that's called within a removed if-block

Children
No Data