# IFDEF Changes explained

**URL:** https://talk.remobjects.com/t/ifdef-changes-explained/14790
**Category:** Elements
**Tags:** elements, oxygene
**Created:** [November 14, 2017, 6:50am UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790 "2017-11-14T06:50:37Z")
**Posts on this page:** 20
**Page:** 3

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [December 19, 2017, 8:09pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/41 "2017-12-19T20:09:04Z")

</div>

`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"`

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [December 19, 2017, 8:41pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/42 "2017-12-19T20:41:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [December 20, 2017, 7:09am UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/43 "2017-12-20T07:09:42Z")

</div>

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

```

Should work fine? Something else must be interfering.

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [December 21, 2017, 10:47am UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/44 "2017-12-21T10:47:12Z")

</div>

> [@DonaldShimoda](#):
>
> How to get that changes? I need to release a new version soon.

We did a new build yesterday.

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [December 21, 2017, 1:59pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/45 "2017-12-21T13:59:15Z")

</div>

Thanks!

---

<div class="post-metadata">

### Author: ![arturredzko](https://talk.remobjects.com/user_avatar/talk.remobjects.com/arturredzko/32/16908_2.png) [@arturredzko](https://talk.remobjects.com/u/arturredzko)
#### Post date: [December 23, 2017, 12:09pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/46 "2017-12-23T12:09:48Z")

</div>

> [@arturredzko](#):
>
> adding uses section in implementation part of unit - compiler ignores define and tries to parse Delphi units in .NET :
> 
> {$IFDEF DCC} uses System.SysUtils ; {$ENDIF}
> 
> raising (E26) Unknown namespace “System.SysUtils” in uses list.

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 ?

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [December 27, 2017, 7:01am UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/47 "2017-12-27T07:01:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![arturredzko](https://talk.remobjects.com/user_avatar/talk.remobjects.com/arturredzko/32/16908_2.png) [@arturredzko](https://talk.remobjects.com/u/arturredzko)
#### Post date: [December 27, 2017, 6:39pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/48 "2017-12-27T18:39:31Z")

</div>

[GisInclude.zip](https://talk.remobjects.com/uploads/default/original/2X/5/5caeb74f69e8920c88a7a0f10cf08fe756772d9d.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).

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [December 28, 2017, 6:04am UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/49 "2017-12-28T06:04:42Z")

</div>

Thanks, logged as bugs://79278

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [December 28, 2017, 6:47am UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/50 "2017-12-28T06:47:04Z")

</div>

bugs://79278 got closed with status fixed.

---

<div class="post-metadata">

### Author: ![Mateusz\_Galazka](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/m/65b543/32.png) [@Mateusz\_Galazka](https://talk.remobjects.com/u/Mateusz_Galazka)
#### Post date: [January 18, 2018, 2:51pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/51 "2018-01-18T14:51:06Z")

</div>

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 ☹

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [January 18, 2018, 3:37pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/52 "2018-01-18T15:37:54Z")

</div>

Create two overloads, one calls the other.

---

<div class="post-metadata">

### Author: ![deltics](https://talk.remobjects.com/user_avatar/talk.remobjects.com/deltics/32/804_2.png) [@deltics](https://talk.remobjects.com/u/deltics)
#### Post date: [January 18, 2018, 9:37pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/53 "2018-01-18T21:37:31Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![Mateusz\_Galazka](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/m/65b543/32.png) [@Mateusz\_Galazka](https://talk.remobjects.com/u/Mateusz_Galazka)
#### Post date: [January 22, 2018, 10:46am UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/54 "2018-01-22T10:46:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [January 22, 2018, 11:38am UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/55 "2018-01-22T11:38:39Z")

</div>

> [@Mateusz\_Galazka](#):
>
> getting errors with variables declared in {$IF ECHOES}

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

> [@Mateusz\_Galazka](#):
>
> (E0) Internal error: System.NotSupportedException: Specified method is not supported.

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

---

<div class="post-metadata">

### Author: ![Mateusz\_Galazka](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/m/65b543/32.png) [@Mateusz\_Galazka](https://talk.remobjects.com/u/Mateusz_Galazka)
#### Post date: [January 22, 2018, 11:42am UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/56 "2018-01-22T11:42:38Z")

</div>

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

> **[LHeczko/TestAndroidECHOES](https://github.com/LHeczko/TestAndroidECHOES)**
>
> Contribute to TestAndroidECHOES development by creating an account on GitHub.

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 ☹

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [January 22, 2018, 12:13pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/57 "2018-01-22T12:13:08Z")

</div>

Thanks, logged as bugs://79409

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [January 22, 2018, 12:14pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/58 "2018-01-22T12:14:30Z")

</div>

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 😉

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [January 22, 2018, 2:29pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/59 "2018-01-22T14:29:07Z")

</div>

bugs://79409 got closed with status fixed.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [January 22, 2018, 7:33pm UTC](https://talk.remobjects.com/t/ifdef-changes-explained/14790/60 "2018-01-22T19:33:36Z")

</div>

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

[Previous page](https://talk.remobjects.com/t/ifdef-changes-explained/14790.md?page=2)

[Next page](https://talk.remobjects.com/t/ifdef-changes-explained/14790.md?page=4)
