| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | [C] access data in dll |
Hi john.
11-May-04 11:28:20, john dumas wrote to All
jd> {at}MSGID: 1:261/38 7beeefa8
jd> {at}TZUTC: -0500
jd> {at}CHARSET: LATIN-1
jd> From: john dumas
jd> Lets say I have an array of char * pointers in dll.hpp called array1. I
jd> can
jd> include dll.hpp in both the dll.cpp and prog.cpp. And the program will be
jd> satified when I try to use it
jd> ( array1 in dll.hpp )
jd> / \
jd> / \
jd> dll.cpp prog .cpp
jd> int __stdcall (*foo)( char **array1 );
jd> foo = ...GetProcAddress...
jd> But, what if array1 is in dll.cpp
jd> ( array1 in dll.cpp )
jd> |
jd> |
jd> prog .cpp
jd> int __stdcall (* foo)( char **array1 );
jd> Undefined symbol ... array1
This is generic advice....
put an extern definition of array1 in in the header file
extern char *array1[ HOW_BIG ];
defining HOW_BIG the aray is isn't critical in case prog1 does sizeof(arrray1)
putting the definition in the header file means that if you declare it
incorrectly in the library source file the compiler should spot the
difference and let you know.
if you leave the extern out you'll end up with two arrays one belonging to
the library and one to the program... which may not be what you want...
I don't know if this advice is compatible with microsoft windows...
I've heard that non private variables local to DLLs get shared between all
programs that link that DLL... AFAIK that feature is unique to windows.
-=> Bye <=-
---
* Origin: Money is the root of all wealth. (3:640/1042)SEEN-BY: 633/267 270 @PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.