Forum > macOS / Mac OS X

Illegal type conversion of "Pobjc_object"

(1/3) > >>

inferno:
Hi,
During Cocoa compilation I get many errors  about illegal type conversion of "Pobjc_object":

NSGraphicsContext.inc(334,13) Error: Illegal type conversion: "Pobjc_object" to "NSImageInterpolation"
NSGraphicsContext.inc(367,13) Error: Illegal type conversion: "Pobjc_object" to "NSCompositingOperation"
NSBox.inc(115,13) Error: Illegal type conversion: "Pobjc_object" to "NSBorderType"
NSBox.inc(120,13) Error: Illegal type conversion: "Pobjc_object" to "NSTitlePosition"
NSBox.inc(145,13) Error: Illegal type conversion: "Pobjc_object" to "NSBoxType"
NSButton.inc(198,13) Error: Illegal type conversion: "Pobjc_object" to "NSCellImagePosition"
NSButton.inc(388,13) Error: Illegal type conversion: "Pobjc_object" to "NSBezelStyle"
NSControl.inc(358,13) Error: Illegal type conversion: "Pobjc_object" to "NSTextAlignment"
NSControl.inc(468,13) Error: Illegal type conversion: "Pobjc_object" to "Single"
NSControl.inc(619,13) Error: Illegal type conversion: "Pobjc_object" to "NSWritingDirection"
NSFont.inc(474,13) Error: Illegal type conversion: "Pobjc_object" to "Single"
...

Any idea how to fix it?

Best regards,
Inferno

Jonas Maebe:
Which FPC version are you building and how?

There is no line 334 in the NSGraphicsContext.inc of either FPC 3.2 or FPC trunk.

inferno:
Hi Jonas,
I use FPC 3.3.1. NSGraphicsContext.inc have 376 lines. Below you have the lines where the errors are generated:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function NSGraphicsContext.imageInterpolation: NSImageInterpolation;begin  Result := NSImageInterpolation(objc_msgSend(Handle, sel_registerName(PChar(StrNSGraphicsContext_imageInterpolation)), [])); //NSGraphicsContext.inc(334,13)    

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function NSGraphicsContext.compositingOperation: NSCompositingOperation;begin  Result := NSCompositingOperation(objc_msgSend(Handle, sel_registerName(PChar(StrNSGraphicsContext_compositingOperation)), []));   //NSGraphicsContext.inc(367,13) end;  


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function NSBox.borderType: NSBorderType;begin  Result := NSBorderType(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_borderType)), []));   //NSBox.inc(115,13)end;

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function NSBox.titlePosition: NSTitlePosition;begin  Result := NSTitlePosition(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_titlePosition)), []));   //NSBox.inc(120,13) end;

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function NSBox.boxType: NSBoxType;begin  Result := NSBoxType(objc_msgSend(Handle, sel_registerName(PChar(StrNSBox_boxType)), []));   //NSBox.inc(145,13) end;  
Best regards,
Inferno

Jonas Maebe:
The trunk version of that file only has 83 lines: https://svn.freepascal.org/svn/fpc/trunk/packages/cocoaint/src/appkit/NSGraphicsContext.inc

The quoted code seems to come from the ancient https://wiki.freepascal.org/PasCocoa code. That has been deprecated for about 10 years now. Also, the above code is wrong. You have to typecast objc_msgSend to the signature of the called message. Calling it as a regular varargs function results wrong parameter passing (mainly on AArch64, but I think also with some types on x86-64). I have to admit I don't immediately see why it would give a compilation error now though.

CCRDude:
Old topic, but since I and another user came across the same error, I looked for the file and found it in two locations:

fpcsrc/packages/cocoaint/src/appkit/NSGraphicsContext.inc (new)
lazarus/lcl/interfaces/carbon/pascocoa/appkit/NSGraphicsContext.inc (old)

How can one make sure FPC/Lazarus uses the new one?
Why is the old one still there?

My project has LCLWidgetType:=cocoa and seems to work; my package with the same source file didn't compile with above error. Currently it does, but I'm unsure why.

Navigation

[0] Message Index

[#] Next page

Go to full version