Using an uninitialized structure

Regan Heath regan at netmail.co.nz
Mon Sep 3 07:33:58 PDT 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



More information about the Digitalmars-d mailing list