"redefinition of struct" error when compiling for Win64

General FreeBASIC programming questions.
cbruce
Posts: 136
Joined: Sep 12, 2007 19:13
Location: Dallas, Texas

"redefinition of struct" error when compiling for Win64

Postby cbruce » Jun 04, 2018 19:35

.
Topic "A tool to draw a simple table"
https://www.freebasic.net/forum/viewtopic.php?f=7&t=25216
... shows a "redefinition of struct" error with a bug report and a fix:

Bug report filled:
#844 gen gcc: C code conflict between array-descriptor/UDT structures when declared/used inside successive scopes
https://sourceforge.net/p/fbc/bugs/844/
...
Re: A tool to draw a simple table
Postby coderJeff » Apr 15, 2018 19:10
Posted a bug fix for bug #844: pull request #72
https://github.com/freebasic/fbc/pull/72

But I'm still finding the same error when compiling some code for Win64 (gcc)...

Code: Select all

D:\FREEBASICX64\00_BRUCE\PCG32_FULL\DODO.BAS: In function 'main':
D:\FREEBASICX64\00_BRUCE\PCG32_FULL\DODO.BAS:32:9: error: redefinition of 'struct $8FBARRAY1Iu7INTEGERE'
     dim byt_idx         as integer
         ^
D:\FREEBASICX64\00_BRUCE\PCG32_FULL\DODO.BAS:21:9: note: originally defined here
     dim ctotalx( 1 to 4) as Integer
         ^
compiling C failed: 'D:\FreeBASICx64\bin\win64\gcc.exe' terminated with exit code 1


Note: If you swap dims around - the error location changes.

Code: Select all

' This is only a test rig...
' This example is to show "redefinition of struct" error when compiling for Win64.
' If compiled for Win32 - it compiles, but does absolutely nothing - it just runs and exits.

union mymod_t
    dim ul    as ulong
    dim ub(4) as ubyte
end union

' Compiles for Win64 if double scoped...

scope
'scope
    dim retvalx as integer
    dim utempx as ulong
    retvalx = 0

    dim mmx as mymod_t
    mmx.ul = 928754ul

    dim cx( 255, 1 to 4) as integer
    dim ctotalx( 1 to 4) as Integer
    cx(1,1) = 5
    ctotalx(1) = 9
'end scope
end scope

scope
    dim retval as integer
    dim utemp as ulong
            '
    dim mm( 1 to 2)     as mymod_t
    dim byt_idx         as integer
    dim track256( 255)  as integer
    dim xlate( 255)     as ubyte
    dim zero_to_255     as integer = 0
end scope
.
MrSwiss
Posts: 3573
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: "redefinition of struct" error when compiling for Win64

Postby MrSwiss » Jun 04, 2018 20:01

Code: Select all

union mymod_t
    dim ul    as ulong
    dim ub(4) as ubyte
end union
Here we have a problem: the ub(4), allocates 5 ubytes, therefore:

Code: Select all

union mymod_t
    dim ul    as ulong
    dim ub(1 To 4) as ubyte
end union
or:

Code: Select all

union mymod_t
    dim ul    as ulong
    dim ub(3) as ubyte  ' aka: ub(0 To 3)
end union

cbruce wrote:But I'm still finding the same error when compiling some code for Win64 (gcc)...
As long as you use 1.05.0, there will be NO fixes included. (only ver. 1.06.0 contains them!)
fxm
Posts: 9817
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: "redefinition of struct" error when compiling for Win64

Postby fxm » Jun 04, 2018 20:16

That compiles on my PC.
What is your fbc 64-bit version and date?

Mine is:
fbc: FreeBASIC Compiler - Version 1.06.0 (05-27-2018), built for win64 (64bit)
cbruce
Posts: 136
Joined: Sep 12, 2007 19:13
Location: Dallas, Texas

Re: "redefinition of struct" error when compiling for Win64

Postby cbruce » Jun 04, 2018 22:31

.
FreeBASIC Compiler - Version 1.06.0 (11-29-2017), built for win64 (64bit)

I'll go see if I can find that 2018 version. Thanks!
cbruce
Posts: 136
Joined: Sep 12, 2007 19:13
Location: Dallas, Texas

Re: "redefinition of struct" error when compiling for Win64

Postby cbruce » Jun 04, 2018 22:42

Ah! Mr Swiss... I can see that the 4 byte vs. 5 byte alignment in the union is *wrong* and I need to fix that. But fixing that did not fix the error. Also, everything in my program was working fine until I added the second SCOPE block. So, does that point out a possible problem with SCOPE blocks - or is it only my bad code - or is it just the wrong fbe.exe version like fxm said?

I'll get the new version and try it.
cbruce
Posts: 136
Joined: Sep 12, 2007 19:13
Location: Dallas, Texas

Re: "redefinition of struct" error when compiling for Win64

Postby cbruce » Jun 04, 2018 23:42

.
Latest build took care of the error... Thanks fxm!

FreeBASIC Compiler - Version 1.06.0 (05-27-2018), built for win64 (64bit)

Return to “General”

Who is online

Users browsing this forum: No registered users and 7 guests