www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



digitalmars.D - a problem with references

↑ ↓ ← Niovol <niovol gmail.com> writes:
How can I use references?
I found an example:
line 1|  //
line 2|  void def(ref int x)
line 3|  {
line 4|      x += 1;
line 5|  }

But this example doesn't work on my computer. The errors appear:
-----------------------
C:\Work\NeuroV.d\main.d(3): found 'int' when expecting ')'
C:\Work\NeuroV.d\main.d(3): semicolon expected following function
declaration
C:\Work\NeuroV.d\main.d(3): no identifier for declarator x
C:\Work\NeuroV.d\main.d(3): semicolon expected, not ')'
C:\Work\NeuroV.d\main.d(3): Declaration expected, not ')'
C:\Work\NeuroV.d\main.d(5): unrecognized declaration
--------
Apr 26 2007
↑ ↓ → Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Niovol wrote:
 How can I use references?
 I found an example:
 line 1|  //
 line 2|  void def(ref int x)
 line 3|  {
 line 4|      x += 1;
 line 5|  }
 
 But this example doesn't work on my computer. The errors appear:
 -----------------------
 C:\Work\NeuroV.d\main.d(3): found 'int' when expecting ')'
 C:\Work\NeuroV.d\main.d(3): semicolon expected following function
 declaration
 C:\Work\NeuroV.d\main.d(3): no identifier for declarator x
 C:\Work\NeuroV.d\main.d(3): semicolon expected, not ')'
 C:\Work\NeuroV.d\main.d(3): Declaration expected, not ')'
 C:\Work\NeuroV.d\main.d(5): unrecognized declaration
 --------

What compiler version are you using? The "ref" keyword was introduced in DMD v1.011, so it won't work in any DMD version before that (nor any GDC version currently released). So if you're using an older version (or GDC) either upgrade or use "inout" instead (that's what it was called before v1.011, and it still works).
Apr 26 2007