Thread overview
importing structs
Nov 06, 2002
J C Calvarese
Nov 06, 2002
Burton Radons
Nov 06, 2002
J C Calvarese
Nov 23, 2002
Walter
November 06, 2002
Hi.

Most of my experience has been in varous forms of BASIC, but I've also programmed in Pascal and Java.  I'm currently learning D.  I find the syntax a lot easier to understand than C++.

I've run into a problem.  I'm using Walter's GUI sample as a framework and adding more Win32 API controls.  I can get it to compile and run fine if I declare these structs (LVITEMA, LVCOLUMNA, SIZE, etc.) in the winsamp.d file, but the instant I move them to the dmd\src\windows.d file, my success ends.  The compiler seems to understand what I did, but the linker seems to be angry at me:

winsamp,,,user32.lib+gdi32.lib+comctl32.lib+user32+kernel32,winsamp.def/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

winsamp.obj(winsamp)
 Error 42: Symbol Undefined __init_windows_LVITEMA
winsamp.obj(winsamp)
 Error 42: Symbol Undefined __init_windows_LVCOLUMNA
winsamp.obj(winsamp)
 Error 42: Symbol Undefined __init_windows_SIZE
winsamp.obj(winsamp)
 Error 42: Symbol Undefined __init_windows_INITCOMMONCONTROLSEX
winsamp.obj(winsamp)
 Error 42: Symbol Undefined __init_windows_TOOLINFOA
winsamp.obj(winsamp)
 Error 42: Symbol Undefined __init_windows_SETTEXTEX
--- errorlevel 6


I'm probably trying to do something stupid.  Do I need to recompile phobos?  Do I need to develop initializer methods for these structures?  I don't have a clue why it works perfectly when I declare these structs in the main program, but it falls apart when I try to put them somewhere else.

Any help would be much appreciated.
Justin


November 06, 2002
J C Calvarese wrote:
> I'm probably trying to do something stupid.  Do I need to recompile phobos?  Do I need to develop initializer methods for these structures?  I don't have a clue why it works perfectly when I declare these structs in the main program, but it falls apart when I try to put them somewhere else.

Yes, you'd need to recompile Phobos; structs have hidden variable data for their initial content.  It's best to keep these structs in your program for now.

November 06, 2002
Thanks.  That explains it.  I'll keep them in the main source.  It struck me as strange that I can move constants wherever I want (as long as I import it) and D doesn't complain, but the D system can't find my structs when I move them.

Justin

Burton Radons wrote:
> J C Calvarese wrote:
> 
>> I'm probably trying to do something stupid.  Do I need to recompile phobos?  Do I need to develop initializer methods for these structures?  I don't have a clue why it works perfectly when I declare these structs in the main program, but it falls apart when I try to put them somewhere else.
> 
> 
> Yes, you'd need to recompile Phobos; structs have hidden variable data for their initial content.  It's best to keep these structs in your program for now.
> 

November 23, 2002
"J C Calvarese" <jccalvarese@yahoo.com> wrote in message news:3DC8928F.3070700@yahoo.com...
> Thanks.  That explains it.  I'll keep them in the main source.  It struck me as strange that I can move constants wherever I want (as long as I import it) and D doesn't complain, but the D system can't find my structs when I move them.

That's because D stores an initializer for the struct in the module that declares it, then when you use a struct, it initializes it with that initializer. The initializer isn't really necessary if the values are all 0, and the compiler shouldn't demand one if so, but the current one does.

-Walter