IFDEF Changes explained

DataAccess = public class({$IFDEF JAVA}android.app.Application, SharedPreferences.OnSharedPreferenceChangeListener{$ELSE}IDARemoteDataAdapterDelegate{$ENDIF) // E179 Method "method onSharedPreferenceChanged(arg1: SharedPreferences; arg2: String)" not implemented as required for interface "SharedPreferences.OnSharedPreferenceChangeListener"

Correct use defined() for that, much cleaner as well.

aLastLocation : {$IFDEF JAVA } Location {$ELSE} CLLocation{$ENDIF};

Should work fine? Something else must be interfering.

We did a new build yesterday.

1 Like

Thanks!

I tried the current build and it’s not fixed. Compiler still tries to parse uses section raising the same error (E26). Why we cannot hide whole uses section in implementation in ifdef ?

Can you show the exact pattern you used here? I thought I had all of it covered but apparently not this one.

GisInclude.zip (6.0 KB)
Two cases in this sample :

  • uses section parsing
  • $include problem if whole unit code is in define (e.g. to skip parsing in documentation tools).

Thanks, logged as bugs://79278

bugs://79278 got closed with status fixed.

I’ve got problem with implementation of methods, with parameters was different in different conditionals.

Example:
Declatarion
{$IFDEF COOPER}
class method Test(aTest: android.content.Context): String;
{$ELSE}
class method Test():String;
{$ENDIF}

I have to copy almost whole body in implementation or divide it into smaller intependent methods - a lot of work to make new version working :frowning:

Create two overloads, one calls the other.

pmfji - How does having two overloads help when not on COOPER, given that in that case there is no android.content.Context ? That overload is simply not going to compile unless COOPER is defined, surely ?

At the very least there will need to be a bunch of other stuff needed to make two overloads work (e.g. a typedef for the parameter type to the parameterised method which in turn is conditionally typed as an alias for Context for COOPER and - presumably - object for non-COOPER).

What am I missing ?

1 Like

Next problem - building android class library I’m getting errors with variables declared in {$IF ECHOES}

f.e.

{$IF ECHOES}
var
  vImage: System.Drawing.Image;
{$ENDIF}

Building Windows class library getting warinings about variables declared in {$IF COOPER}

{$IF ECHOES}
{$ELSEIF COOPER}
var vByteArray :  array of SByte;
{$ENDIF}

And finally error

(E0) Internal error: System.NotSupportedException: Specified method is not supported.
       at RemObjects.Oxygene.Code.BaseVisitor.VisitTypeReference(TypeReference element)
       at RemObjects.Oxygene.Code.BaseVisitor.VisitIfdefTypeReference(IfdefTypeReference element)
       at RemObjects.Oxygene.Code.BaseVisitor.VisitTypeReference(TypeReference element)
       at RemObjects.Oxygene.Code.BaseVisitor.VisitIfdefTypeReference(IfdefTypeReference element)
       at RemObjects.Oxygene.Code.BaseVisitor.VisitTypeReference(TypeReference element)
       at RemObjects.Oxygene.Code.Compiler.LambdaAcquirer.VisitVarDefinition(VarDefinition element)
       at RemObjects.Oxygene.Code.BaseVisitor.VisitVarStatement(VarStatement varStatement)
       at RemObjects.Oxygene.Code.BaseVisitor.VisitStatement(Statement element)
       at RemObjects.Oxygene.Code.Compiler.LambdaAcquirer.VisitStatement(Statement element)
       at RemObjects.Oxygene.Code.BaseVisitor.VisitBeginStatement(BeginStatement beginStatement)
       at RemObjects.Oxygene.Code.Compiler.LambdaAcquirer.VisitBeginStatement(BeginStatement beginStatement)
       at RemObjects.Oxygene.Code.BaseVisitor.VisitStatement(Statement element)
       at RemObjects.Oxygene.Code.Compiler.LambdaAcquirer.VisitStatement(Statement element)
       at RemObjects.Oxygene.Code.Compiler.Compiler.<>c__DisplayClass41.<GenerateAnonymousTypes>b__2(IMethodInfo methm)
       at RemObjects.Oxygene.Code.CombinedParsedType.ForAllMethods(Func`2 action)
       at RemObjects.Oxygene.Code.Compiler.Compiler.GenerateAnonymousTypes(LambdaAcquirer& lWACQ, MyDictionary`1 aTypes)
       at RemObjects.Oxygene.Code.Compiler.Compiler.Compile()	

New version of course

hard to say anything about this without knowing what the error is…

that’s a bug, for sure. well need the project that shows this, to fix it.

Building android ClassLib
(E28) Unknown type “System.Drawing.Image”

method Class1.Test;
{$IFDEF ECHOES}
var
vImage: System.Drawing.Image;
{$ENDIF}
begin

end;

It builds with error,

method Class1.Test;
begin
{$IFDEF ECHOES}
var
vImage: System.Drawing.Image;
{$ENDIF}

end;

It build normally.

I’ve created new windows project to test if there is no problem but still the same. I’ll try to find where is the error cutting project into small parts - it’s a big project :frowning:

Thanks, logged as bugs://79409

Logged a bug for the vart thing; but for now, the best fix would be ti just move the vars into the begin, where they really belong, in the 21st century :wink:

bugs://79409 got closed with status fixed.

I’m gonna close this thread, as its getting long. lets start new, individual threads formally new issues or questions that arise about $ifdef.