Wish [SOLVED]compiler conditional execution

Discussion in 'B4R Bugs & Wishlist' started by Laurent95, Nov 4, 2018.

  1. Laurent95

    Laurent95 Active Member Licensed User

    Hello,
    That would be nice to have multiple conditions in compiler conditional execution, ie #if xxx or yyyy, or maybe #if isdefined(xxx) or isdefined(yyy), etc.
    A bit like in C++.
    A simple case : That would extend possibilities to test two different configurations, in two modes : debug, no debug.

    Thanks
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Laurent95

    Laurent95 Active Member Licensed User

    Hello Erel,
    Maybe i didn't explain properly :oops:, i know this thread, since long time.
    But the most important in my sentence it's the "OR", probably understood like i gave 2 different examples :(

    By the "or", i want mean a logical operator in the condition. Ok a good picture valued better than a long explain, so i did screenshots.
    condional compiler1.png condional compiler2.png

    If i put that in B4R it's because there is no debug mode.
    But as i saw that a comment like 'ignore can be used to interact with the IDE.
    I know, i do some weird things sometimes, maybe it's because i was during long time beta tester on many products ;)

    So i had thinked that it's maybe possible to have this great improvement, in B4R, who can replace the missing 'debug mode" :).
    Then, my wish stay in standby. If that's possible of course, soon Christmas ;).

    Have a nice day.

    P.S.: I thinked it's possible coz in C forms in conditional compiler we can use "is defined(xxx || yyy), i had did that many time
     
    Last edited: Nov 4, 2018
  4. Erel

    Erel Administrator Staff Member Licensed User

    Please upload a small program that demonstrates it.
     
  5. Laurent95

    Laurent95 Active Member Licensed User

    Ok, Give me time, it not compile too big ;)
    Need to clean it a bit.
     
  6. Laurent95

    Laurent95 Active Member Licensed User

    Ok this version compiling (that was 101% program code, fortunatly), it give an error on execution "Out of bounds error. Array length = 0, Index = 0', no time to see why, it's not all debuged yet.

    But at least that allow, i hope, to see the difference with 2 conditions in the #if. There are all conditions in project like on my screenshots.
    I didn't put the libaries it's my "low memory µC stay alive" source, but a bit more implemented.

    If it's too cumbersome to see with this code, tell me, i can do a simple light example if yu want, but i need more time :).

    EDIT November 5: deleted the attached example who don't show properly the things
     
    Last edited: Nov 5, 2018
  7. Erel

    Erel Administrator Staff Member Licensed User

    I don't see the condition that doesn't work properly. You need to upload the project that fails to compile.
     
  8. Laurent95

    Laurent95 Active Member Licensed User

    Ok let me do a sample example, that's certainely not compile for you coz the libraries.
    I'll, just need time.

    Have a nice end of WE
     
  9. Laurent95

    Laurent95 Active Member Licensed User

    Hello,
    @Erel, I put SOLVED in title because i found a solution who works. But if you want to displace the thread it's ok for me.
    It's logical, but my first mistake is probably due to confusion in both syntaxes of B4R and Arduino.
    So i forget that we can manage it in B4x, but without logical operators in conditional compiler code.
    Instead we must put several conditions in setup project for some cases.
    Sorry, it's a bit difficult to stay concentrated between the both syntaxes, especially in the same project. And for repeat the things like on screenshots i can't today all work fine :confused:.

    Ok, so it's possible to do, need to use imbriqued conditions and need to respect the exact order of conditions who it used in the example. All explanations are in the code in comments
    This example works in the 2 modes with conditional compiler who compile only the right code.
    There is also 2 other conditions to allow debug or release modes, even if B4R don't manage the 2 modes.

    That's good, it was what i needed, hope the example can help:).

    Have a nice day.
     

    Attached Files:

    Last edited: Nov 5, 2018
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice