Compiler error messages

Forum for discussion about the documentation project.
Psyche_Demon
Posts: 46
Joined: Jul 30, 2015 8:07
Location: England
Contact:

Compiler error messages

Postby Psyche_Demon » Jan 12, 2017 23:09

Hi,
Naturally, when I get an error message during compilation, the first place I tend to check is the FB documentation. The problem with that is, while it gives an ordered list of all the different errors it is possible to get, I can't find anywhere that explains, even briefly, what these errors could mean.
Of course, some are blatantly obvious (Well, they are if you know about simple programming concepts):
◾ 1 Argument count mismatch
◾ 2 Expected End-of-File
◾ 3 Expected End-of-Line
◾ 4 Duplicated definition
...

Some are less obvious unless you know exactly where in the documentation to look and what concepts to look for:
◾ 208 Illegal non-static member access
◾ 261 Invalid initializer
◾ 309 Invalid size
◾ 319 Reference not initialized
◾ 320 Incompatible reference initializer

Is there a more detailed list of what the error messages actually mean? If not, I believe it could be of great help, especially for people who are new to FreeBASIC.
Cheers.
Tourist Trap
Posts: 2355
Joined: Jun 02, 2015 16:24

Re: Compiler error messages

Postby Tourist Trap » Jan 13, 2017 2:20

Maybe we could use this thread to gather and share our knowledge about the errors we meet. So after a while the most common ones would be commented and maybe it would be added somewhere as a documentation page some day.
fxm
Posts: 8051
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Compiler error messages

Postby fxm » Jan 13, 2017 7:31

For each non-obvious compiler message, could you give a short example of code producing that, in order to perhaps improve the error sentence if necessary ?

For example for the first:

Code: Select all

Type UDT
  Dim As Integer I
  Declare Sub s ()
End Type

Sub UDT.s ()
  Print UDT.I
End Sub
error 208: Illegal non-static member access, found 'I' in 'Print UDT.I'
Psyche_Demon
Posts: 46
Joined: Jul 30, 2015 8:07
Location: England
Contact:

Re: Compiler error messages

Postby Psyche_Demon » Jan 13, 2017 9:44

Hi,
Most of these errors I obtained from the docs, so unfortunately I wouldn't know when they would be triggered, until I actually came across them.
The example you gave about nonstatic members still doesn't make sense - I would have thought that should trigger an error with UDT rather than UDT.I, given that it would logically be trying to access UDT.UDT.I which of course doesn't exist.
Funnily enough I got that error with something totally different - when trying to pass a function inside a type as a function pointer to something that is outside the type.

Code: Select all

type test
declare function tish() as long
declare function tosh() as long
private:
dummy as boolean ''The compiler complains about empty types otherwise.
end type

function foo(byval bar as function() as long) as long
return bar()+123
end function

function test.tish() as long
return 5
end function

function test.tosh() as long
return foo(@tish)
end function

dim test as boing

beep
boing.tosh


I got the same error when I changed
return foo(@tish)
to
return foo(@test.tish)
So goodness knows how you use function pointers/callbacks with UDT's and namespaces.
fxm
Posts: 8051
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Compiler error messages

Postby fxm » Jan 13, 2017 10:03

Your code with the second error corrected:

Code: Select all

type test
declare function tish() as long
declare function tosh() as long
private:
dummy as boolean ''The compiler complains about empty types otherwise.
end type

function foo(byval bar as function() as long) as long
return bar()+123
end function

function test.tish() as long
return 5
end function

function test.tosh() as long
return foo(@tish)
end function

'dim test as boing
dim boing as test

beep
boing.tosh
error 208: Illegal non-static member access, TEST.TISH in 'return foo(@tish)'

One can get the address only from static procedures:

Code: Select all

type test
'declare function tish() as long
declare static function tish() as long
declare function tosh() as long
private:
dummy as boolean ''The compiler complains about empty types otherwise.
end type

function foo(byval bar as function() as long) as long
return bar()+123
end function

function test.tish() as long
return 5
end function

function test.tosh() as long
return foo(@tish)
end function

'dim test as boing
dim boing as test

beep
print boing.tosh
Psyche_Demon
Posts: 46
Joined: Jul 30, 2015 8:07
Location: England
Contact:

Re: Compiler error messages

Postby Psyche_Demon » Jan 13, 2017 10:15

Hi,
Oh oops, yeah. Second error was embarrassingly easy. Just whipped it up as an example so didn't do much real looking over. Lol.
So looks like I'll have to look at static vs. non-static functions then.
Is the documentation open for anyone to edit? Perhaps I could start working on a proper error definition index myself if I knew how.
Cheers.
fxm
Posts: 8051
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Compiler error messages

Postby fxm » Jan 13, 2017 10:31

Psyche_Demon wrote:Is the documentation open for anyone to edit?
In theory yes, but in practice, it does not seem.
To see with the admins.

Psyche_Demon wrote:Perhaps I could start working on a proper error definition index myself if I knew how.
Warning: Compiler error messages and associated error code values may change at each revision, making it difficult to refer those to an index (numeric or alphabetical).
For me, the best could be to directly improve the compiler error sentences.
Psyche_Demon
Posts: 46
Joined: Jul 30, 2015 8:07
Location: England
Contact:

Re: Compiler error messages

Postby Psyche_Demon » Jan 13, 2017 10:49

Hi,
The warnings are already listed from 1 to 39 and errors from 1 to 323 in numeric order. All it needs is an explanation next to each one. If any warnings/error codes/messages do change, this document would have to be updated anyway.
Cheers.
fxm
Posts: 8051
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Compiler error messages

Postby fxm » Jan 13, 2017 11:40

About the documentation page:
Compiler Error Messages :
dkl wrote:That page can be autogenerated from the fbc source code, using the fbchkdoc tools, I did it during the last FB releases.
(Jan 22, 2012)
In summary, do not edit this page yet!
Psyche_Demon
Posts: 46
Joined: Jul 30, 2015 8:07
Location: England
Contact:

Re: Compiler error messages

Postby Psyche_Demon » Jan 13, 2017 12:16

Gotcha. Yeah, I guess it would be tricky to add a more descriptive index to that document then, if it's all automatic.

Return to “Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest