Closed headscott closed 6 months ago
A bug is a bug and should be fixed instead of masked. We don't want to implement such gcc feature for lazy programmers. A portable solution according to the C standard is to cast types (if you want to do such a dangerous thing) or use "void *" or union. If you are doing such dangerous things, it is your business to handle them properly. Do not ask to change the compiler.
Okay, I will change them then in my code. I just hoped there is already something possible to do that.
But according to the other error message:
If I compile this file:
#define SIZE 64*1024
int buf[SIZE];
This error appears:
Error! Error E1020: Dimension cannot be 0 or negative
Even if I do
int buf[65536];
It gives me the error:
Error! Error E1157: Variable must be 'huge'
Is it also a bug in my code or does wcc have other limitations here? Can I do that without errors?
I just need to declare the array as '__huge' right?
int __huge buf[65536];
But then wcc says
Error! E1098: Maximum struct or union size is 64K
And what about the define? I would not want to set all used positions by hand if I change the size again
you can use macro for array size as usual. What you mean by define exactly, it is regular array? Only address calculation is done as for huge object that it is always normalize to segm:>offset( 0-0x0F)
I mean I want to be able to do
#define SIZE 65536
as well as
#define SIZE 64*1024
and my struct which contains an array of SIZE unsigned char elements, but also other variables, got too big. See that error:
Error! E1098: Maximum struct or union size is 64K
and I cannot declare my struct as '__huge'
I don't understand why you have a problem. below is sample code using __huge object which compile OK.
int __huge a[MAX];
int __huge *test( int i )
{
return( &a[i] );
}
and dissasembled code
PUBLIC test_
PUBLIC _a
EXTRN __PIA:BYTE
EXTRN _small_code_:BYTE
DGROUP GROUP CONST,CONST2,_DATA
_TEXT SEGMENT BYTE PUBLIC USE16 'CODE'
ASSUME CS:_TEXT, DS:DGROUP, SS:DGROUP
test_:
push bx
push cx
push si
cwd
mov si,ax
mov cx,dx
shl si,1
rcl cx,1
mov ax,offset _a
mov dx,seg _a
mov bx,si
call near ptr __PIA
pop si
pop cx
pop bx
ret
_TEXT ENDS
CONST SEGMENT WORD PUBLIC USE16 'DATA'
CONST ENDS
CONST2 SEGMENT WORD PUBLIC USE16 'DATA'
CONST2 ENDS
_DATA SEGMENT WORD PUBLIC USE16 'DATA'
_DATA ENDS
huge13_DATA SEGMENT PARA PRIVATE USE16 'FAR_DATA'
_a:
DB 1fffH DUP(0,0,0,0,0,0,0,0)
DB 0, 0, 0, 0, 0, 0, 0, 0
huge13_DATA ENDS
huge14_DATA SEGMENT PARA PRIVATE USE16 'FAR_DATA'
DB 1fffH DUP(0,0,0,0,0,0,0,0)
DB 0, 0, 0, 0, 0, 0, 0, 0
huge14_DATA ENDS
huge15_DATA SEGMENT PARA PRIVATE USE16 'FAR_DATA'
DB 0, 0
huge15_DATA ENDS
END
__PIA is special "huge" pointer aritmetic function to add index and create output normalized pointer.
I also use a struct where I did something like this:
#define MAX 64*1024 //first problem here, need to define to 65536 by hand (why?/how can I do it with 64*1024 anyways?)
typedef struct
{
int element;
int __huge buffer[MAX]; //this one exceeds 64K which seems to be the max size of structs
} __huge elementname;
and get this error:
Error! E1098: Maximum struct or union size is 64K
It is clear what you do wrong, single huge object cannot be > 65536 bytes. You cannot add huge array to structure. It is bad design. You can use huge array of structures where size of struct < 65536 bytes.
Wait... can I fix this by using wcc386 instead of wcc?
wcc is for 16-bit architecture (segmented 64kBytes) but wcc386 for 32-bit architecture I suppose that you know it.
Yeah true... thank you anyways. I would need to rearrange my files a bit
I compiled a c-file with wcc, but it says
If I compile the exact same file with gcc and these options:
-w -ffreestanding -c
there is no error reported, it's just a warning (I can see it, if I remove -w option).Is there a way, that wcc also treat this "error" as a warning?
Edit: There is another error appearing:
Error! Error E1020: Dimension cannot be 0 or negative
the line code looks like this:
uint8_t code_buf[CODE_BUF_SIZE]
and
CODE_BUF_SIZE
is defined in an enum:enum { CODE_BUF_SIZE = 24*1024, ....};
so it is > 0