Re: [ooc-compiler] Type Constructors and Export Marks
Brought to you by:
mva
|
From: Stewart G. <sgr...@ii...> - 2005-12-06 02:53:13
|
Hi August,
Looks like you found a bug.
For me, the compiler accepts that module. The error is from the C
compiler during code generation.
obj/M.d:4: error: conflicting types for 'M__x'
obj/M.oh:11: error: previous declaration of 'M__x' was here
obj/M.d:4: error: conflicting types for 'M__x'
obj/M.oh:11: error: previous declaration of 'M__x' was here
I think there is a slight problem with the output of type declarations.
In this case, "x" is exported, so oo2c needs to generate an "extern"
declaration for "x" in M.oh (public headers for module M). Although it
is the same declaration, this conflicts with the local declaration of
"x" in M.d (private headers for module M). This is because C uses name
equivalence, not structural equivalence for records. Its probably not a
problem for other type constructors (eg. pointers, arrays) because they
use structural equivalence in C.
What oo2c needs to do is to output a separate declaration for the type
of "x" in M.oh. Normal Oberon-2 style is to declare names for most
types, which is possibly why this problem has not been noticed.
For example:
MODULE M;
TYPE T = POINTER TO RECORD y-: LONGINT END;
VAR x-: T;
END M.
In this case you already have a declaration for the type, which is used
for both variable declarations in the C code. Especially for records,
you need a name for the type in order to pass the record type by
reference (eg. as a VAR parameter), or to extend the record type.
Cheers,
Stewart
August Karlstrom wrote:
> Hi,
>
> Is the following module is invalid?
>
> MODULE M;
> VAR x-: POINTER TO RECORD y-: LONGINT END;
> END M.
>
> OOC 2.1.9 thinks it is. Why?
>
>
> Regards,
>
> August
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> ooc-compiler mailing list
> ooc...@li...
> https://lists.sourceforge.net/lists/listinfo/ooc-compiler
>
|