digitalmars.D - Using an uninitialized structure
- B.Schulte (10/10) Sep 03 2007 Hi.
- 0ffh (3/4) Sep 03 2007 Tried "CHAR_INFO[] buffer;" ?
- Regan Heath (24/41) Sep 03 2007 Where is the definition of the CHAR_INFO structure? Have you defined it...
- B. Schulte (6/34) Sep 03 2007 Well, the CHAR_INFO structure is stored in the win32.wincon file. There ...
- Regan Heath (14/53) Sep 03 2007 There is, but I don't believe it has anything to do with the error
- B. Schulte (4/65) Sep 03 2007 Well, it really wasn't declared as extern(C). But I inserted it and decl...
- Regan Heath (6/72) Sep 03 2007 I can't see the win32.wincon file in the svn for that project:
- B. Schulte (8/83) Sep 03 2007 Sorry, I was wrong. Here is the official Project page:
- Regan Heath (34/119) Sep 03 2007 This works for me:
- Regan Heath (7/46) Sep 03 2007 I've found win32.wincon here:
- Sean Kelly (4/13) Sep 03 2007 Unfortunately, I don't think there's a way to use the "=void" when
- Walter Bright (4/10) Sep 03 2007 The init symbol for a struct is placed into the object file generated by...
Hi. I don't get it working. So I ask here. There is the problem: CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } If I try to compile this (even without the foreach) I get a linker error. The Linker can't find the __INIT symbol of the CHAR_INFO structure. Well, sure - there IS NO __init symbol - But I don't WANT to init it somehow else. I can't get it working :(( Thanks in advance for every help :)
Sep 03 2007
B.Schulte wrote:CHAR_INFO buffer[];Tried "CHAR_INFO[] buffer;" ? Regards, Frank
Sep 03 2007
B.Schulte wrote:Hi. I don't get it working. So I ask here. There is the problem: CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } If I try to compile this (even without the foreach) I get a linker error. The Linker can't find the __INIT symbol of the CHAR_INFO structure. Well, sure - there IS NO __init symbol - But I don't WANT to init it somehow else. I can't get it working :(( Thanks in advance for every help :)Where is the definition of the CHAR_INFO structure? Have you defined it in your code? eg. import std.c.windows.windows; extern(C) { struct CHAR_INFO { union _Char { WCHAR UnicodeChar; CHAR AsciiChar; } _Char Char; WORD Attributes; } alias CHAR_INFO* PCHAR_INFO; } void main() { CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } } Regan
Sep 03 2007
Well, the CHAR_INFO structure is stored in the win32.wincon file. There was something I took from dsource to use the winAPI methods. I didn't want to write in orginal files to fix a problem. I thought about fixing the problem somewhere else. (Don't modify the wincon.d) However, it still doesn't work. Error 42: Symbol Undefined _D5win326wincon9CHAR_INFO6__initZ There must be some way to use uninitialized variables :( Regan Heath Wrote:Where is the definition of the CHAR_INFO structure? Have you defined it in your code? eg. import std.c.windows.windows; extern(C) { struct CHAR_INFO { union _Char { WCHAR UnicodeChar; CHAR AsciiChar; } _Char Char; WORD Attributes; } alias CHAR_INFO* PCHAR_INFO; } void main() { CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } } Regan
Sep 03 2007
B. Schulte wrote:Regan Heath Wrote:There is, but I don't believe it has anything to do with the error you're getting. :) You are missing a symbol, the symbol you are missing is mangled in such a way that it is clear that it is a D symbol, which means you have defined CHAR_INFO as a D struct, instead of using extern (C) as I have shown you above. What dsource project is win32.wincon in? Perhaps CHAR_INFO isn't declared as extern (C) in there... FYI, you can allocate an array of CHAR_INFO structures without initialising like this: CHAR_INFO[500] abuffer = void; this is a fixed length array however, perhaps not what you want? ReganWhere is the definition of the CHAR_INFO structure? Have you defined it in your code? eg. import std.c.windows.windows; extern(C) { struct CHAR_INFO { union _Char { WCHAR UnicodeChar; CHAR AsciiChar; } _Char Char; WORD Attributes; } alias CHAR_INFO* PCHAR_INFO; } void main() { CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } } ReganWell, the CHAR_INFO structure is stored in the win32.wincon file. There was something I took from dsource to use the winAPI methods. I didn't want to write in orginal files to fix a problem. I thought about fixing the problem somewhere else. (Don't modify the wincon.d) However, it still doesn't work. Error 42: Symbol Undefined _D5win326wincon9CHAR_INFO6__initZ There must be some way to use uninitialized variables :(
Sep 03 2007
Regan Heath Wrote:B. Schulte wrote:Well, it really wasn't declared as extern(C). But I inserted it and declared it as extern(C). Don't know why, but it still don't work. Here is the dsource project: http://dsource.org/projects/core32Regan Heath Wrote:There is, but I don't believe it has anything to do with the error you're getting. :) You are missing a symbol, the symbol you are missing is mangled in such a way that it is clear that it is a D symbol, which means you have defined CHAR_INFO as a D struct, instead of using extern (C) as I have shown you above. What dsource project is win32.wincon in? Perhaps CHAR_INFO isn't declared as extern (C) in there... FYI, you can allocate an array of CHAR_INFO structures without initialising like this: CHAR_INFO[500] abuffer = void; this is a fixed length array however, perhaps not what you want? ReganWhere is the definition of the CHAR_INFO structure? Have you defined it in your code? eg. import std.c.windows.windows; extern(C) { struct CHAR_INFO { union _Char { WCHAR UnicodeChar; CHAR AsciiChar; } _Char Char; WORD Attributes; } alias CHAR_INFO* PCHAR_INFO; } void main() { CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } } ReganWell, the CHAR_INFO structure is stored in the win32.wincon file. There was something I took from dsource to use the winAPI methods. I didn't want to write in orginal files to fix a problem. I thought about fixing the problem somewhere else. (Don't modify the wincon.d) However, it still doesn't work. Error 42: Symbol Undefined _D5win326wincon9CHAR_INFO6__initZ There must be some way to use uninitialized variables :(
Sep 03 2007
B. Schulte wrote:Regan Heath Wrote:I can't see the win32.wincon file in the svn for that project: http://dsource.org/projects/core32/browser/trunk/core32/win32 I retract my comment about extern (C) I think maybe this has something to do with how you're compiling it, the command line you're using. ReganB. Schulte wrote:Well, it really wasn't declared as extern(C). But I inserted it and declared it as extern(C). Don't know why, but it still don't work. Here is the dsource project: http://dsource.org/projects/core32Regan Heath Wrote:There is, but I don't believe it has anything to do with the error you're getting. :) You are missing a symbol, the symbol you are missing is mangled in such a way that it is clear that it is a D symbol, which means you have defined CHAR_INFO as a D struct, instead of using extern (C) as I have shown you above. What dsource project is win32.wincon in? Perhaps CHAR_INFO isn't declared as extern (C) in there... FYI, you can allocate an array of CHAR_INFO structures without initialising like this: CHAR_INFO[500] abuffer = void; this is a fixed length array however, perhaps not what you want? ReganWhere is the definition of the CHAR_INFO structure? Have you defined it in your code? eg. import std.c.windows.windows; extern(C) { struct CHAR_INFO { union _Char { WCHAR UnicodeChar; CHAR AsciiChar; } _Char Char; WORD Attributes; } alias CHAR_INFO* PCHAR_INFO; } void main() { CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } } ReganWell, the CHAR_INFO structure is stored in the win32.wincon file. There was something I took from dsource to use the winAPI methods. I didn't want to write in orginal files to fix a problem. I thought about fixing the problem somewhere else. (Don't modify the wincon.d) However, it still doesn't work. Error 42: Symbol Undefined _D5win326wincon9CHAR_INFO6__initZ There must be some way to use uninitialized variables :(
Sep 03 2007
Regan Heath Wrote:B. Schulte wrote:Sorry, I was wrong. Here is the official Project page: http://www.prowiki.org/wiki4d/wiki.cgi?WindowsAPI However, here is my command line: compiling: dmd [files] -c -O -op -D -debug -version=WindowsXP linking: dmd [files]Regan Heath Wrote:I can't see the win32.wincon file in the svn for that project: http://dsource.org/projects/core32/browser/trunk/core32/win32 I retract my comment about extern (C) I think maybe this has something to do with how you're compiling it, the command line you're using. ReganB. Schulte wrote:Well, it really wasn't declared as extern(C). But I inserted it and declared it as extern(C). Don't know why, but it still don't work. Here is the dsource project: http://dsource.org/projects/core32Regan Heath Wrote:There is, but I don't believe it has anything to do with the error you're getting. :) You are missing a symbol, the symbol you are missing is mangled in such a way that it is clear that it is a D symbol, which means you have defined CHAR_INFO as a D struct, instead of using extern (C) as I have shown you above. What dsource project is win32.wincon in? Perhaps CHAR_INFO isn't declared as extern (C) in there... FYI, you can allocate an array of CHAR_INFO structures without initialising like this: CHAR_INFO[500] abuffer = void; this is a fixed length array however, perhaps not what you want? ReganWhere is the definition of the CHAR_INFO structure? Have you defined it in your code? eg. import std.c.windows.windows; extern(C) { struct CHAR_INFO { union _Char { WCHAR UnicodeChar; CHAR AsciiChar; } _Char Char; WORD Attributes; } alias CHAR_INFO* PCHAR_INFO; } void main() { CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } } ReganWell, the CHAR_INFO structure is stored in the win32.wincon file. There was something I took from dsource to use the winAPI methods. I didn't want to write in orginal files to fix a problem. I thought about fixing the problem somewhere else. (Don't modify the wincon.d) However, it still doesn't work. Error 42: Symbol Undefined _D5win326wincon9CHAR_INFO6__initZ There must be some way to use uninitialized variables :(
Sep 03 2007
B. Schulte wrote:Regan Heath Wrote:I thought it might be.B. Schulte wrote:Sorry, I was wrong. Here is the official Project page: http://www.prowiki.org/wiki4d/wiki.cgi?WindowsAPIRegan Heath Wrote:I can't see the win32.wincon file in the svn for that project: http://dsource.org/projects/core32/browser/trunk/core32/win32 I retract my comment about extern (C) I think maybe this has something to do with how you're compiling it, the command line you're using. ReganB. Schulte wrote:Well, it really wasn't declared as extern(C). But I inserted it and declared it as extern(C). Don't know why, but it still don't work. Here is the dsource project: http://dsource.org/projects/core32Regan Heath Wrote:There is, but I don't believe it has anything to do with the error you're getting. :) You are missing a symbol, the symbol you are missing is mangled in such a way that it is clear that it is a D symbol, which means you have defined CHAR_INFO as a D struct, instead of using extern (C) as I have shown you above. What dsource project is win32.wincon in? Perhaps CHAR_INFO isn't declared as extern (C) in there... FYI, you can allocate an array of CHAR_INFO structures without initialising like this: CHAR_INFO[500] abuffer = void; this is a fixed length array however, perhaps not what you want? ReganWhere is the definition of the CHAR_INFO structure? Have you defined it in your code? eg. import std.c.windows.windows; extern(C) { struct CHAR_INFO { union _Char { WCHAR UnicodeChar; CHAR AsciiChar; } _Char Char; WORD Attributes; } alias CHAR_INFO* PCHAR_INFO; } void main() { CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } } ReganWell, the CHAR_INFO structure is stored in the win32.wincon file. There was something I took from dsource to use the winAPI methods. I didn't want to write in orginal files to fix a problem. I thought about fixing the problem somewhere else. (Don't modify the wincon.d) However, it still doesn't work. Error 42: Symbol Undefined _D5win326wincon9CHAR_INFO6__initZ There must be some way to use uninitialized variables :(However, here is my command line: compiling: dmd [files] -c -O -op -D -debug -version=WindowsXP linking: dmd [files]This works for me: [charinfo.d] import std.c.windows.windows; import win32.wincon; void main() { CHAR_INFO[] buffer; CHAR_INFO[500] abuffer = void; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } } Compiled like so: E:\D\src\tmp>dmd charinfo.d -c -O -op -D -debug -version=WindowsXP E:\D\src\tmp>dmd e:\d\win32\win32\wincon.d -c -O -op -D -debug -version=WindowsXP E:\D\src\tmp>dmd charinfo.obj e:\d\win32\win32\wincon.obj E:\D\dmd\bin\..\..\dm\bin\link.exe charinfo+e:\d\win32\win32\wincon,,,user32+kernel32/noi; Note, this fails giving the error you mentioned because I am not compiling and linking with wincon.d: E:\D\src\tmp>dmd charinfo.d E:\D\dmd\bin\..\..\dm\bin\link.exe charinfo,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved charinfo.obj(charinfo) Error 42: Symbol Undefined _D5win326wincon9CHAR_INFO6__initZ --- errorlevel 1 If I include it in the compile and link, it works: E:\D\src\tmp>dmd charinfo.d e:\d\win32\win32\wincon.d E:\D\dmd\bin\..\..\dm\bin\link.exe charinfo+wincon,,,user32+kernel32/noi; Regan
Sep 03 2007
B. Schulte wrote:Regan Heath Wrote:I've found win32.wincon here: http://www.dsource.org/projects/bindings/browser/trunk/win32/wincon.d Is that the one you used? I think you had better post your entire source file and the command line you are using to compile. ReganWhere is the definition of the CHAR_INFO structure? Have you defined it in your code? eg. import std.c.windows.windows; extern(C) { struct CHAR_INFO { union _Char { WCHAR UnicodeChar; CHAR AsciiChar; } _Char Char; WORD Attributes; } alias CHAR_INFO* PCHAR_INFO; } void main() { CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } } ReganWell, the CHAR_INFO structure is stored in the win32.wincon file. There was something I took from dsource to use the winAPI methods. I didn't want to write in orginal files to fix a problem. I thought about fixing the problem somewhere else. (Don't modify the wincon.d) However, it still doesn't work. Error 42: Symbol Undefined _D5win326wincon9CHAR_INFO6__initZ There must be some way to use uninitialized variables :(
Sep 03 2007
B.Schulte wrote:Hi. I don't get it working. So I ask here. There is the problem: CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; }Unfortunately, I don't think there's a way to use the "=void" when initializing arrays. Sean
Sep 03 2007
B.Schulte wrote:CHAR_INFO buffer[]; buffer.length = 100; foreach( inout CHAR_INFO ci; buffer ) { ci.Char.AsciiChar = ' '; ci.Attributes=7; } If I try to compile this (even without the foreach) I get a linker error. The Linker can't find the __INIT symbol of the CHAR_INFO structure.The init symbol for a struct is placed into the object file generated by the source module that defines that struct. In this case, you need to link in the compiled module that defines CHAR_INFO.
Sep 03 2007