Tk Source Code

View Ticket
Login
Ticket UUID: 1ccface1c5107b308a1a7be15987853565e6e711
Title: tkMacOSXFileTypes.c does not compile on 10.15
Type: Bug Version: core-8-6-branch
Submitter: chrstphrchvz Created on: 2022-09-20 15:24:46
Subsystem: 83. Mac OS X Build Assigned To: marc_culler
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-11-15 01:40:25
Resolution: Fixed Closed By: marc_culler
    Closed on: 2026-11-15 01:40:25
Description:

tk/macosx/tkMacOSXFileTypes.c:79:20: error: use of undeclared identifier 'UTType'
        UTType *uttype = [UTType typeWithIdentifier: filetype];
                          ^
tk/macosx/tkMacOSXFileTypes.c:79:2: error: use of undeclared identifier 'UTType'
        UTType *uttype = [UTType typeWithIdentifier: filetype];
        ^
tk/macosx/tkMacOSXFileTypes.c:79:10: error: use of undeclared identifier 'uttype'
        UTType *uttype = [UTType typeWithIdentifier: filetype];
                ^
tk/macosx/tkMacOSXFileTypes.c:80:8: error: use of undeclared identifier 'uttype'
        if (![uttype isDeclared]) {
              ^
tk/macosx/tkMacOSXFileTypes.c:81:6: error: use of undeclared identifier 'uttype'
            uttype = [UTType typeWithFilenameExtension: filetype];
            ^
tk/macosx/tkMacOSXFileTypes.c:81:16: error: use of undeclared identifier 'UTType'
            uttype = [UTType typeWithFilenameExtension: filetype];
                      ^
tk/macosx/tkMacOSXFileTypes.c:83:8: error: use of undeclared identifier 'uttype'
        if (![uttype isDeclared] && [filetype length] == 4) {
              ^
tk/macosx/tkMacOSXFileTypes.c:86:6: error: use of undeclared identifier 'uttype'; did you mean 'ostype'?
            uttype = [UTType typeWithIdentifier:UTI];
            ^~~~~~
            ostype
tk/macosx/tkMacOSXFileTypes.c:84:13: note: 'ostype' declared here
            OSType ostype = CHARS_TO_OSTYPE(filetype.UTF8String);
                   ^
tk/macosx/tkMacOSXFileTypes.c:86:16: error: use of undeclared identifier 'UTType'
            uttype = [UTType typeWithIdentifier:UTI];
                      ^
tk/macosx/tkMacOSXFileTypes.c:88:8: error: use of undeclared identifier 'uttype'
        if (![uttype isDeclared]) {
              ^
tk/macosx/tkMacOSXFileTypes.c:91:40: warning: instance method '-iconForContentType:' not found (return type defaults to 'id') [-Wobjc-method-access]
        return [[NSWorkspace sharedWorkspace] iconForContentType:uttype];
                                              ^~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWorkspace.h:27:12: note: receiver is instance of class declared here
@interface NSWorkspace : NSObject
           ^
tk/macosx/tkMacOSXFileTypes.c:91:59: error: use of undeclared identifier 'uttype'
        return [[NSWorkspace sharedWorkspace] iconForContentType:uttype];
                                                                 ^
tk/macosx/tkMacOSXFileTypes.c:91:40: warning: instance method '-iconForContentType:' not found (return type defaults to 'id') [-Wobjc-method-access]
        return [[NSWorkspace sharedWorkspace] iconForContentType:uttype];
                                              ^~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWorkspace.h:27:12: note: receiver is instance of class declared here
@interface NSWorkspace : NSObject
           ^
2 warnings and 11 errors generated.

User Comments: marc_culler (claiming to be Marc Culler) added on 2026-11-15 00:10:57:
I built 8.6 with the patch-1ccface1 branch merged into the tip of
core-86-branch on macOS 10.13 and 10.15.  Also on macOS 15 with a
minimum deployment target of 10.15 and with both a minimum and
a maximum deployment target of 10.15.  All of the builds worked
with only the expected warnings (i.e. scrollRect:by: is deprecated).

There were test failures, but that is another story.

I think this can be merged.

chrstphrchvz added on 2026-11-03 15:37:25:

Revised patch committed, please see branch patch-1ccface1. Compare to structure of preceding function TkMacOSXOSTypeToUTI().


chrstphrchvz added on 2022-09-23 18:04:43:

The patch is simpler, and better, but it does not avoid a warning in the case where MIN_REQUIRED == MAX_ALLOWED == 12.0, say. That is because there is no else block for the if (@available) block in that case.

I had not realized this, however I would deal with it just by introducing a result variable. Would that still be simpler? See patch 1ccface1c510-result.diff (based on core-8-6-branch)


marc_culler (claiming to be Marc Culler) added on 2022-09-22 15:44:01:
Thank you!

I moved the } inside of the #if ... #endif block, where it belongs.
I tried adding
#define MAC_OS_X_VERSION_MAX_ALLOWED 101500
#define MAC_OS_X_VERSION_MIN_REQUIRED 101500
at the top of the tkMacOSXFileTypes.c source file and the compiler did
not report any syntax errors.  So I think it may finally be correct.

chrstphrchvz added on 2022-09-22 14:43:22:

tk/macosx/tkMacOSXFileTypes.c:114:1: error: extraneous closing brace ('}')
}
^
1 error generated.


marc_culler (claiming to be Marc Culler) added on 2022-09-21 23:27:24:
Pending the drop of the other shoe.

marc_culler (claiming to be Marc Culler) added on 2022-09-21 20:04:19:
Thanks!

The patch is simpler, and better, but it does not avoid a warning
in the case where MIN_REQUIRED == MAX_ALLOWED == 12.0, say. That
is because there is no else block for the if (@available) block
in that case.

I wish Apple would deal with this problem in a better way.

chrstphrchvz added on 2022-09-21 18:53:46:

[3e83ac71ca45] does build on 10.15, but it leads to a warning:

tk/macosx/tkMacOSXFileTypes.c:105:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
}
^

See the attached patch 1ccface1c510-alt.diff (based on latest tkMacOSXFileTypes.c in core-8-6-branch); would these changes both avoid the warning and be simpler?


marc_culler (claiming to be Marc Culler) added on 2022-09-21 15:16:27:
Can anyone test to make sure the bug-fix branch now builds on 10.15?
I can't do it right now.

marc_culler (claiming to be Marc Culler) added on 2022-09-20 16:00:27:
Thank you Christopher.  I added an #if ... #endif pair which will hopefully
fix this.  I put it in a bugfix branch bug-1ccface1c5 in case there are more.

Would you please try again?  Thanks!

Attachments: