IFDEF Changes explained

I see. Not sure we’ll have a simple solution for that, aside from declaring the types twice, sorry. Carlo might have more insight tomorrow.

Yes, it’s long story how we cooperated with Carlo in this matter. Right now we must declare the type twice because there is no “alias” trick.

Sorry my friend, Cleaner? For who? The actual option is cleaner to me. Your option is not more clear, Is just compatible with Elements V 10. Period. And is incompatible with Delphi/Freepsacal compiler . Despite the fact a lot of code is inherited from delphi, will not be anymore, need to be rewrited specifically for Element, break of compabilitiy. Not a good thing for me , despite any other benefit to come from this accoridng to Carlo comments.

The real cleaner option is a common property for all RO/DA objects being the same for all the frameworks. That will be really cleaner!

I have a project working fine in android and ios, now i have to rewrite this, not even chance of compile on old Fire V 9.x version and test on android device. Why? No valid reason rigth now. Just the fact the new element compiler becomes incomatible with previous version. In a strong way. Bad solution my friend, Very bad breaking changes.

All the changes you proposes seems like hacks not needed. The only reason i need is for dont break the new compiler or builder. When you must reinvent the wheel with code doing nothing something is going very wrong… like defining a dumble class i will never use in a plattform? Is a poor programing techinque for me, sorry. Thats is the flexibility i must expect on the Element compiler? Sorry, i disagree big time!

I dont have another option. Just let me say is a big dissapoint for me that breaking changes. Im sure will not be more happy than now when i finish to do that stupid code rewrite. Very dissapointing.

Sorry, we disagree this time.

1 Like

We’ve had this discussion 37 tines already. Yes, DA is not currently designed for cross platform use, as it predates Elements on non-.NET and was designed for each platform specifically. That’s something we will address in good time (as also discussed before). But that is completely orthogonal to Elements v10, and getting hung up on that here is contra-productive.

Ok, that was a little complain. What about the real big elephant in the room?

Thanks, logged as bugs://79247 for conditional ifdef on record/class/interface.

bugs://79247 got closed with status fixed.

This now compiles:

type
  ABC = public {$IFDEF TEST}class{$ELSE}record{$ENDIF}
    b: Integer;
  end;

@ck I’m trying to convert this to v10

  SQLiteConnection = public {$IFDEF PUREJAVA}interface{$ELSE}class{$ENDIF} {$IFDEF ANDROID}mapped to android.database.sqlite.SQLiteDatabase{$ENDIF}
  {$IFDEF PUREJAVA}mapped to java.sql.Connection{$ENDIF}{$IFDEF ECHOES}(IDisposable){$ENDIF}
  private
end;

I don’t know how to handle the (IDisposable), I tried several combinations with no luck:

 SQLiteConnection = public 
    {$IFDEF PUREJAVA}interface
    {$ELSE}class{$ENDIF} 
   
       {$IFDEF ANDROID}mapped to android.database.sqlite.SQLiteDatabase
      {$ELSEIF PUREJAVA}mapped to java.sql.Connection
       {$ENDIF}

       {$IFDEF ECHOES}
       // (IDisposable) 
       {$ENDIF}
      private
        end;

This should work:
(Object {$IFDEF X}, IDisposable{$ENDIF})

mmm This works:

 SQLiteConnection = public 
    {$IFDEF PUREJAVA}interface
    {$ELSE}class{$ENDIF} 
      (Object
   {$IFDEF ECHOES}
   ,IDisposable
   {$ENDIF}
       )

   {$IFDEF ANDROID}mapped to android.database.sqlite.SQLiteDatabase
   {$ELSEIF PUREJAVA}mapped to java.sql.Connection
   {$ENDIF}
    

  private
       method Dispose;empty;
    end;

Thanks!
But now I’m thinking what an interface(Object) means?
And class(Object) mapped to… ?

class(Object) works ofc, interface needs some thought.

bugs://79236 got closed with status fixed.

Any chance to make this work?

No, but you can put the ancestors themselves in the ifdef?

DataAccess = public class({$IFDEF JAVA}android.app.Application, SharedPreferences.OnSharedPreferenceChangeListener{$ELSE}IDARemoteDataAdapterDelegate{$ENDIF)
...
end;```

Great, this is acceptable now. Thanks.

That will never get accepted? just to confirm.

How to get that changes? I need to release a new version soon.

@DonaldShimoda
Hi Donald,
have you tried:

if {$IFDEF JAVA}
   aBriefCase.TableNames.length > 0
   {$ELSE}
   aBriefCase.tableNames.count > 0
   {$ENDIF} then
1 Like

Yes, this works fine. Thanks!

Another poblem (inside a class)

aLastLocation : {$IFDEF JAVA } Location {$ELSE} CLLocation{$ENDIF}; // E625 Defines must be defined at the start of the file
                                                                    // E276 Cannot use $ELSE twice within $IFDEF
                                                                    // E278 No matching $IFDEF for $ELSE