Menu

#Ifdef & 2 Subs with same name

ToniG
2022-06-10
2022-06-19
  • ToniG

    ToniG - 2022-06-10

    I'm using #Define & #Ifdef, Ifndef to select 1 of 2 subroutines to select 2 different serial addressing modes.
    The Sub's need to be the same name as they are commands in a library (include file).

    It looks like 'Overloaded Subroutines' is preceding the #Ifdef, Ifndef.

    I made some quick test code attached...
    First 2 subs (Sub Test1) with issue, works perfect with Subs 3 & 4 Sub Test2 & Sub Test3

     #chip 12F683,8
    #config Osc = Int
    Dim X2 as String *10
    
    #Define TestMode1
    
    Main:
        Test1
        Test2  
        Test3
    
    Goto Main
    
    
    'Same name subs issue with Overloading
    #Ifdef TestMode1
    Sub Test1
         X2 = "First"
    
    End Sub
    #Endif
    
    #Ifndef TestMode1
    Sub Test1
         X2 = "Secnd"
    
    End Sub
    #Endif
    '*********************************
    
    'Different name subs ok
    #Ifdef TestMode1
    Sub Test2
         X2 = "TestMode1"
    
    End Sub
    #Endif
    
    #Ifndef TestMode1
    Sub Test3
         X2 = "TestMode2"
    
    End Sub
    #Endif
    
     
  • ToniG

    ToniG - 2022-06-11

    Probably just the cold mornings & not enough antifreeze...
    Putting the #Ifdef, #Ifndef code sections inside the 1 sub works ok

     
  • ToniG

    ToniG - 2022-06-11

    Is it normal to take much longer to compile with 1 each #IFdef & #Ifndef is a program ?
    1.79s without & 7.91s with.
    Just curious.

     
    • Anobium

      Anobium - 2022-06-11

      Post the program and I can have a look.

      It all depends on what the code within you program is calling. But, it does sound a little odd from your timings.

       
  • ToniG

    ToniG - 2022-06-11

    Attached test code showing compile time.
    However, it is odd indeed! in reverting (undo, undo...) the code that took 9.7s now is 1.4s. Did a file compare to be sure.
    The other program I am working on also compiles fast again now (no code changes).
    I am using the hex button in Synwrite IDE. If I notice this again I will restart the IDE & see.

     
    • Anobium

      Anobium - 2022-06-12

      How strange.

      The 9.7s code to takes 0.87s here. I removed&enabled to constant but the time is still sub 0.9s.

      A mystery. Am I testing incorrectly?

       
  • ToniG

    ToniG - 2022-06-12

    Is probably a win7 anomaly.
    I was running previously SimulIDE & it crashes a bit.
    Thanks for checking

    I also remember crashing the compiler when I forgot to add the # to the Endif,
    This may have upset something temporarily.

     

    Last edit: ToniG 2022-06-14
  • Anobium

    Anobium - 2022-06-19

    Case closed ? Put it down to an OS anomaly.

     

Log in to post a comment.