Error XS9041 STRICT and CLIPPER

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Anonymous

Error XS9041 STRICT and CLIPPER

Post by Anonymous »

Hello,

We use our own class of DBServer called DBServerKl, where we inherit DBServerKl and overwrite some of its methods, this used to work fine in VO, however, when converted to X#, we get the error:

XS9041 Override of virtual method 'Close' has STRICT calling convention but overridden method in parent class is CLIPPER.

XS9041 Override of virtual method 'Commit' has STRICT calling convention but overridden method in parent class is CLIPPER.

Also we have in Project/Properties "Implicit Clipper" on false, after this advice:
https://www.xsharp.eu/forum/public-prod ... rt=10#4521

However if we would put it on true, it would probably work but we would get the XS1558 error again in InitializeComponent, so this would not help us.

Here is the code:

Code: Select all

CLASS DBServerKL  INHERIT DBServer 

method Close() class DBServerKl
	if nDBTeller > 0
		--nDBTeller 
	endif
	
	super:Close()
	
	RETURN TRUE

method Commit() class DBServerKl

	local lOk as logic

	// dbg(str( self:recno)) 
	if self:EoF  
		//LOGGZ("Commit",self:Name+": Commit op EOF record", cMedewerker, cDatapath)
		
	elseif self:RLOCK()
		lOk := super:Commit() 
		if !lOk                      //niet gelukt ?
			if self:STATus==null_object
				LOGGZ("Commit",self:Name+": Commit niet gelukt. Status onbekend", cMedewerker, cDatapath)
			else
				LOGGZ("Commit",self:Name+": Commit niet gelukt: "+self:STATus:description, cMedewerker, cDatapath)
			endif 
		endif 
	else
		if self:STATus==null_object
			LOGGZ("Commit",self:Name+": Rlock niet gelukt. Status onbekend", cMedewerker, cDatapath)
		else
			LOGGZ("Commit",self:Name+": Rlock niet gelukt: "+self:STATus:description, cMedewerker, cDatapath)
		endif 
	endif
	self:UnLock() 
	
	return lOk 

(more unrelated methods that do seem to get inherited fine here)
END CLASS
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Error XS9041 STRICT and CLIPPER

Post by Chris »

Hi Jelle,

The root of this problem is that it is not possible for the compiler to know if you mean to define a method without argument as a CLIPPER or STRICT calling convention method. For methods with parameters:

METHOD TestStrict(n AS INT , s AS STRICT)
METHOD TestClipper(n , s)

it is obvious that the first one is strongly typed (STRICT), but the other has CLIPPER calling convention.

By default the compiler treats parameterless methods as STRICT, because this is the modern/safer/faster way, unless you use the implicit clipper compiler option.

But CLIPPER and STRICT methods are considered as completely different methods (which just happen to have the same name), so you get the compiler error, because it does not make sense (and can cause problems) to override a CLIPPER method with a STRICT one and vice versa. In VO, there is no such issue, because VO does not support method overloading at all.

Anyway, after explaining the matter more deeply, fortunately the solution is simple, just declare the calling convention (CLIPPER) explicitly:

method Close() CLIPPER
method Commit() CLIPPER

now it should all work fine.

hth,
Chris
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Jello5

Error XS9041 STRICT and CLIPPER

Post by Jello5 »

Hello Chris, thank you for replying so quick and the explination. Clipper is something I have not a lot of experience with so this is very helpful.

I thought I did this before, but I just wrote:
method Close() class DBServerK AS CLIPPER
and
method Close() class DBServerK CLIPPER

Ofcourse this wasn't going to work so I just figured I must have forgotten something, glad to know that it is that simple. It does work now indeed.
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Error XS9041 STRICT and CLIPPER

Post by Chris »

Hi Jelle,

Glad it works now! CLIPPER calling convention just means that parameters are not typed (as it was in Clipper), you can actually pass more or less params when calling the method than the number of params the method defines etc and it is what VO uses by default, too. Of curse there's no compile time checking for CLIPPER methods, which makes them more error prone, but they are necessary for compatibility with VO (and other Clipper dialects) code.

Chris
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply