PDA

View Full Version : Very odd "Record, object or class type required" error



chronozphere
08-05-2010, 10:54 PM
Hey guys,

I can't get my code to compile. it says:



[Pascal Error] n3d_shaderprogram.pas(184): E2018 Record, object or class type required



procedure Test(const a: TVector4f);
var
d: Single;
begin
d := a.x; //error here
end;


Defined in another unit:


PVector4f = ^TVector4f;
TVector4f = record
case Boolean of
true: ( x, y, z, w: Single; );
false: ( xyzw: array [0..3] of Single; );
end;


It works for TVector2f and TVector3f. Only TVector4f makes problems. >:( :(

I cant test it in Delphi 2010 because the SDL unit won't compile there (I don't think I can reproduce it by just isolating these routines... I tried that).

I tried compiling with lazarus. But it didn't help. It gave the following error:


G:\n3d\workingdir\src\n3d_shaderprogram.pas(184,9) Error: Illegal qualifier


Any ideas? I'm really stuck here. :(

User137
09-05-2010, 07:57 AM
I get that error sometimes from something really simple, i recompile all units and error goes away. Problem is that Lazarus didn't compile some changed unit for whatever reason. In Lazarus you can do that by adding space after any code line so it becomes "modified". 1 thing that can do that (but may not be the issue always) is in Project options -> Miscellaneous -> Always build toggled off.

But there are always some issues with Lazarus, do you have latest daily snapshot or a very old "stable" build? :p

chronozphere
09-05-2010, 08:57 AM
A guy from another forum pointed out that this could be caused by the wrong type being used. This was actually the case. ;)

dglOpenGL.pas also defines a TVector4f structure. Because this unit was the last one in the uses-clause, it was overwriting the typedef from n3d_vectors.pas. That's what caused the issue.

User137
09-05-2010, 02:04 PM
Oh yes, mouse-over hint reveals the true source type and unit it was taken from.