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

D - array declaration bug

↑ ↓ ← "Pavel Minayev" <evilone omen.ru> writes:
The following code (from WinAPI headers) doesn't compile:

    const int SIZE_OF_80387_REGISTERS = 80;
    ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea;

It tells that "integer constant expression" is expected...
Dec 24 2001
↑ ↓ Lars Ivar Igesund <larsivar igesund.net> writes:
Pavel Minayev wrote:
 The following code (from WinAPI headers) doesn't compile:
 
     const int SIZE_OF_80387_REGISTERS = 80;
     ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea;
 
 It tells that "integer constant expression" is expected...
 

This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund
Mar 11 2004
=?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Lars Ivar Igesund wrote:
 Pavel Minayev wrote:
 
 The following code (from WinAPI headers) doesn't compile:

     const int SIZE_OF_80387_REGISTERS = 80;
     ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea;

 It tells that "integer constant expression" is expected...

This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund

Don't work? void main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); } Output: RegisterArea.size = 80 DMD 0.81 for linux Julio
Mar 11 2004
Lars Ivar Igesund <larsivar igesund.net> writes:
Julio Jiménez wrote:

 Lars Ivar Igesund wrote:
 
 Pavel Minayev wrote:

 The following code (from WinAPI headers) doesn't compile:

     const int SIZE_OF_80387_REGISTERS = 80;
     ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea;

 It tells that "integer constant expression" is expected...

This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund

Don't work? void main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); } Output: RegisterArea.size = 80 DMD 0.81 for linux Julio

Wrong circumstances. (My cancelled message was plain wrong, btw). ---- array.d ------ const int FOO = 100; int[FOO] arr; ------------------- don't compile at all. Lars Ivar Igesund
Mar 11 2004
→ =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Lars Ivar Igesund wrote:
 Julio Jiménez wrote:
 
 Lars Ivar Igesund wrote:

 Pavel Minayev wrote:

 The following code (from WinAPI headers) doesn't compile:

     const int SIZE_OF_80387_REGISTERS = 80;
     ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea;

 It tells that "integer constant expression" is expected...

This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund

Don't work? void main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); } Output: RegisterArea.size = 80 DMD 0.81 for linux Julio

Wrong circumstances. (My cancelled message was plain wrong, btw). ---- array.d ------ const int FOO = 100; int[FOO] arr; ------------------- don't compile at all. Lars Ivar Igesund

void main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); const int FOO = 100; int [FOO] arr; printf("arr.size = %d\n", arr.size); } Output: RegisterArea.size = 80 arr.size = 400 That's all right..... What dmd version do you have? regards Julio
Mar 11 2004
→ J C Calvarese <jcc7 cox.net> writes:
Lars Ivar Igesund wrote:
 

 
 Wrong circumstances. (My cancelled message was plain wrong, btw).
 
 ---- array.d ------
 
 const int FOO = 100;
 int[FOO] arr;
 
 -------------------
 
 don't compile at all.

It compiles for me (on WinXP Home), but it doesn't link (there's no main). build.bat: echo off dmd array.d -c pause Output: Press any key to continue . . . If I add a main it compiles, links, and runs. array.d: const int FOO = 100; int[FOO] arr; void main() { printf("It works for me.\n"); } Output: d:\dmd\bin\..\..\dm\bin\link.exe array,,,user32+kernel32/noi; It works for me. Press any key to continue . . . HTH
 
 Lars Ivar Igesund

-- Justin http://jcc_7.tripod.com/d/
Mar 11 2004
→ "Walter" <walter digitalmars.com> writes:
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message
news:c2qj99$pvh$3 digitaldaemon.com...
 ---- array.d ------

 const int FOO = 100;
 int[FOO] arr;

 -------------------

 don't compile at all.

It works when I try it: ------------------------------- C:\cbx\mars>type test.d const int FOO = 100; int[FOO] arr; C:\cbx\mars>dmd -c test C:\cbx\mars>obj2asm test _TEXT segment dword use32 public 'CODE' ;size is 0 _TEXT ends _DATA segment para use32 public 'DATA' ;size is 4 _DATA ends CONST segment para use32 public 'CONST' ;size is 0 CONST ends _BSS segment para use32 public 'BSS' ;size is 400 _BSS ends FLAT group public _D4test3FOOi public _D4test3arrG100i _TEXT segment assume CS:_TEXT _TEXT ends _DATA segment _D4test3FOOi: db 064h,000h,000h,000h _DATA ends CONST segment CONST ends _BSS segment _BSS ends end C:\cbx\mars>
Mar 11 2004
→ =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Lars Ivar Igesund wrote:

 
 Sorry. I meant static arrays:
 
 const int FOO = 100;
 static int [FOO] arr;
 
 I also see that I don't need the static part, so I drop the charges.
 
 Lars Ivar Igesund
 

void main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); const int FOO = 100; static int [FOO] arr; printf("arr.size = %d\n", arr.size); } Output: RegisterArea.size = 80 arr.size = 400 It's ok.... ;-) (int size = 4 bytes) Regards Julio
Mar 11 2004
Lars Ivar Igesund <larsivar igesund.net> writes:
Lars Ivar Igesund wrote:
 Pavel Minayev wrote:
 
 The following code (from WinAPI headers) doesn't compile:

     const int SIZE_OF_80387_REGISTERS = 80;
     ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea;

 It tells that "integer constant expression" is expected...

This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund

I'm sorry about the fuzz here, but the bug is there somewhat. What I really did was this: ---------------------- array.d ---------------------- char [FOO] array; const int FOO = 100; int main() { return 0; } ---------------------- This don't compile with dmd 0.81 with the message "array.d(1): Integer constant expression expected instead of FOO" If I switch lines 1 and 2, it works. It's a bug IMHO but the workaround is simple. Lars Ivar Igesund
Mar 14 2004
↑ ↓ =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Lars Ivar Igesund wrote:
 Lars Ivar Igesund wrote:
 
 Pavel Minayev wrote:

 The following code (from WinAPI headers) doesn't compile:

     const int SIZE_OF_80387_REGISTERS = 80;
     ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea;

 It tells that "integer constant expression" is expected...

This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund

I'm sorry about the fuzz here, but the bug is there somewhat. What I really did was this: ---------------------- array.d ----------------------char [FOO] array;

int main() { return 0; }
 char [FOO] array;
 const int FOO = 100;
 
 int main()
 {
   return 0;
 }
 ----------------------
 
 This don't compile with dmd 0.81 with the message
 "array.d(1): Integer constant expression expected instead of FOO"
 
 If I switch lines 1 and 2, it works. It's a bug IMHO but the
 workaround is simple.
 
 Lars Ivar Igesund

He He..... You are trying to use FOO before define it..... ;-) change the lines order to.... const int FOO = 100; char [FOO] array; int main() { return 0; } and compiles ok regards again... Julio
Mar 14 2004
↑ ↓ Lars Ivar Igesund <larsivar igesund.net> writes:
Julio Jiménez wrote:

 Lars Ivar Igesund wrote:
 
 Lars Ivar Igesund wrote:

 Pavel Minayev wrote:

 The following code (from WinAPI headers) doesn't compile:

     const int SIZE_OF_80387_REGISTERS = 80;
     ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea;

 It tells that "integer constant expression" is expected...

This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund

I'm sorry about the fuzz here, but the bug is there somewhat. What I really did was this: ---------------------- array.d ----------------------char [FOO] array;

const int FOO = 100; int main() { return 0; }
 char [FOO] array;
 const int FOO = 100;

 int main()
 {
   return 0;
 }
 ----------------------

 This don't compile with dmd 0.81 with the message
 "array.d(1): Integer constant expression expected instead of FOO"

 If I switch lines 1 and 2, it works. It's a bug IMHO but the
 workaround is simple.

 Lars Ivar Igesund

He He..... You are trying to use FOO before define it..... ;-) change the lines order to.... const int FOO = 100; char [FOO] array; int main() { return 0; } and compiles ok regards again... Julio

I accept this (and understand) but the error message imply that the problem is something else than an undefined symbol. Lars Ivar Igesund
Mar 14 2004
↑ ↓ → Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
I think that D is supposed to allow these types of forward declarations. 
  Certainly, it allows other types of forward declartions....

Russ

Lars Ivar Igesund wrote:
 I accept this (and understand) but the error message imply that
 the problem is something else than an undefined symbol.
 
 Lars Ivar Igesund

Mar 15 2004