| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | PROB.C 1/2 |
PE>#include
PE>struct mystruct {
PE> int x;
PE>};
PE>struct mystruct __far16 *func(void);
a 32 bit function that returns a 16 bit pointer? How does it find a 16
bit pointer? It should be
struct mystruct __far16 * __far16 __cdecl func(void);
to be a 16 bit function returning a 16 bit pointer. However, if it
really is a 32 bit function, leave it as it is.
PE>int main(void)
PE>{
PE> struct mystruct __far16 *a;
This is the problem. By the time "a" gets the pointer it should have
been thunked back to 32 bits. It should be
struct mystruct *a;
The important thing is not that "a" is a 16 bit pointer. You don't want
a 16 bit pointer. You want a 32 bit pointer to a 16 bit data segment.
The important thing is that since the compiler knows that the function
returns a 16 bit pointer, it automatically converts it to the
appropriate 32 bit pointer.
PE> a = func();
PE> printf("x is %d\n", a->x);
PE> return (0);
PE>}
I'm not sure exactly what you are doing here. I have a solution that
works if my assumptions about your intentions are correct. I have an
assembly routine that must be assembled into a 16 bit .OBJ file and
linked to the 32 bit .OBJ file that BCC creates from my .C code.
#include
struct mystruct {
int x;
};
struct mystruct __far16 * __far16 __cdecl func(void);
int main(void)
{
struct mystruct *a;
a = func();
printf("x is %d\n", a->x);
return (0);
}
/*
.386
_mine segment word use16 public 'DATA'
_var dd 5 ;dword data in a 16 bit data segment
_mine ends
_minetoo segment word use16 public 'CODE'
assume cs:_minetoo
public _func
_func proc far ;returns a 16 bit pointer to data in 16
mov dx,seg _var ;bit data segment
mov ax,offset _var
ret
_func endp
_minetoo ends
end
*/
.
--- QScan v1.14b / 01-0169
* Origin: The Party Line * Memphis * 901-755-4531 (1:123/5)SEEN-BY: 12/2442 620/243 624/50 632/348 640/820 690/660 711/409 410 413 430 SEEN-BY: 711/807 808 809 934 942 949 712/353 515 713/888 800/1 7877/2809 @PATH: 123/5 4 301 3615/50 229/2 12/2442 711/409 808 809 934 |
|
| 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™.