View Issue Details

IDProjectCategoryView StatusLast Update
0035995FPCPackagespublic2019-08-24 12:05
ReporterZoë Peterson Assigned To 
Status newResolutionopen 
Product Version3.3.1 
Summary0035995: CocoaInt: Fix {$if defined} blocks with garbage that break Lazarus code tools
DescriptionThe attached patch corrects two cases where the Cocoa headers use weird but supported syntax that breaks Lazarus's code tools. From the mailing list discussion, the resulting code should be the same either way.
TagsNo tags attached.
Fixed in Revision
Attached Files


Zoë Peterson

2019-08-23 00:56


cocoa-ifdef-fix.patch (1,043 bytes)   
Index: packages/cocoaint/src/foundation/
--- packages/cocoaint/src/foundation/	(revision 42765)
+++ packages/cocoaint/src/foundation/	(working copy)
@@ -1,6 +1,6 @@
 { Parsed from Foundation.framework NSExtensionContext.h }
-{$if defined(__OBJC2__)defined(interface)defined(NSExtensionContext)defined(NSObject)}
+{$if defined(__OBJC2__)}
   NSExtensionItemsAndErrorsKey: NSString { available in 10_10, 8_0 }; cvar; external;
Index: packages/cocoaint/src/webkit/
--- packages/cocoaint/src/webkit/	(revision 42765)
+++ packages/cocoaint/src/webkit/	(working copy)
@@ -13,7 +13,7 @@
   WKWebViewPtr = ^WKWebView;
-{$if defined(TARGET_OS_IPHONE)defined(interface)defined(WKWebView)defined(UIView)}
+{$if defined(TARGET_OS_IPHONE)}
 {$ifdef CLASSES}
cocoa-ifdef-fix.patch (1,043 bytes)   

Thaddy de Koning

2019-08-23 08:43

reporter   ~0117788

Last edited: 2019-08-23 08:55

View 3 revisions

Shouldn't it be:
{$if defined(TARGET_OS_IPHONE) and defined(interface) and defined(WKWebView) and defined(UIView)}
That should not break code tools and still takes the other options into consideration.
I suspect they weren't there for nothing. Alternatively:
{$if defined(TARGET_OS_IPHONE)}{$if defined(interface)}{$if defined(WKWebView)}{$if defined(UIView)}
should also do the trick.

(Or is that weird syntax implicit "or" instead of "and"?)

Sven Barth

2019-08-23 16:19

manager   ~0117799

See also Jonas' answer on the mailing list:

Thaddy de Koning

2019-08-23 16:59

reporter   ~0117800

Last edited: 2019-08-23 17:06

View 4 revisions

Ah, I see, I forgot... silly me ... (* I reported* that everything after a valid evaluation is a comment, btw.....New documentation reflects that.)
Anyway, if the values are significant they should be solved in a way I suggested. ("and" or "or", I suppose "and")

{$if defined(TARGET_OS_IPHONE)<=== this part is evaluated..... but ===> the rest are comments and not evaluated at all!!! ==> defined(interface)defined(WKWebView)defined(UIView) }

I do not think that was the intention.... In that case the patch is wrong/not complete.

Zoë Peterson

2019-08-23 18:04

reporter   ~0117806

There aren't any other checks for "defined(interface)" anywhere else in the headers and the original C .h files just have simple #IFDEF OBJC2/TARGET_OS_IPHONE checks, which corresponds with what I changed it to. I don't know where the original corruption came from, but I don't think the extra text was intentional. I don't use either of these components though, so I may have missed something.

Thaddy de Koning

2019-08-23 18:14

reporter   ~0117807

Last edited: 2019-08-23 18:15

View 2 revisions

I understand, but let's wait what the maintainer thinks of this.
A couple of and's can make a huge difference in meaning.

Sven Barth

2019-08-24 12:05

manager   ~0117821

It might be a bug in the converter for the headers, but then it should be solved there and not in the generated files (and Lazarus should nevertheless correctly handle such expressions as well).

Issue History

Date Modified Username Field Change
2019-08-23 00:56 Zoë Peterson New Issue
2019-08-23 00:56 Zoë Peterson File Added: cocoa-ifdef-fix.patch
2019-08-23 08:43 Thaddy de Koning Note Added: 0117788
2019-08-23 08:48 Thaddy de Koning Note Edited: 0117788 View Revisions
2019-08-23 08:55 Thaddy de Koning Note Edited: 0117788 View Revisions
2019-08-23 16:19 Sven Barth Note Added: 0117799
2019-08-23 16:59 Thaddy de Koning Note Added: 0117800
2019-08-23 17:01 Thaddy de Koning Note Edited: 0117800 View Revisions
2019-08-23 17:04 Thaddy de Koning Note Edited: 0117800 View Revisions
2019-08-23 17:06 Thaddy de Koning Note Edited: 0117800 View Revisions
2019-08-23 18:04 Zoë Peterson Note Added: 0117806
2019-08-23 18:14 Thaddy de Koning Note Added: 0117807
2019-08-23 18:15 Thaddy de Koning Note Edited: 0117807 View Revisions
2019-08-24 12:05 Sven Barth Note Added: 0117821