Git Product home page Git Product logo

silicon's Introduction

Silicon.h

macos

An alternative, single-header and purely C-focused wrapper to Apple's Cocoa API for MacOS app development. Requires little to no Objective-C knowledge to use.

alt text

Why Silicon?

Because there isn't anything else like it (to my knowledge, at least). If you want to create low-level MacOS apps, you have to learn how to use Objective-C effectively, and as we all know the language is notorious for its syntax and its unique (albeit terrible) way of handling object-oriented programming. It also ruins cross-platform code as if you compile an Objective-C file as C, you get a bunch of errors (however somewhat sophisticated build system help that).

A lot of people to that would say "Just use swift instead". While Swift does provide a better syntax than Objective-C (not in all cases), some issues still persist. Swift, much like Objective-C, is still only really used for Apple development and nothing else. It's not really worth learning an even more radically different language to create low-level applications (and personally speaking I don't really care for Swift). The biggest flunder when it comes to cross-platform development would have to be the fact that Swift is very hard to integrate in non Apple-oriented projects, which is a far cry from Objective-C considering it's just C with sugar syntax. Either way, Objective-C prevails in this department.

Apart from Objective-C/Swift, you can also use 3rd-party libraries that obfuscate this whole issue for you. While fine for more higher-level projects, for developers that need total low-level control to satisfy their needs, this isn't suffice. There is also hidefromkgb's mac_load, which allows for actual Mac development in "pure" C. While I do like the project (and have used some of its code in this codebase), there's a lot left to be desired. Using it feels like you're still writing Objective-C code in C with how you need to define your own classes constantly and using programming concepts only found in Objective-C. Due to this much of the written code also looks quite ugly and quite unsensible comparing to the original Objective-C counterpart. It's also not being maintained anymore.

Silicon provides a full C functional-oriented programming wrapper over Cocoa for those low-level programmers in need, as well as anyone that doesn't really want to learn Objective-C or Swift. This library provides a full suite of functions, types, macros, enums, etc from the Cocoa to make a C-syntax friendly library.

Full discloser

As with any young FOSS project, Silicon is subjected to major change in the future and as such massive overhauls should be expected.

Silicon is also very unfinished as a complete implementation of a giant library like Cocoa will take awhile to achieve. As of now, Silicon will firstly focus on implementing the Cocoa essentials, plus common code examples and functions used in the API.

Silicon on iOS (Beta)

As of Aprill 11th of 2023, it's possible to compile basic C code with Silicon's Makefile. While GUI support is nowhere near implemented, it's already possible to print something in the terminal with the print.c example.

Prerequisites

  • Xcode:
    • iOS SDK.
    • iOS simulator.
  • Silicon's Makefile.
  • Setting said Makefile's TARGET_iOS to true at line 6.

Building

To build, install and launch the app all at once, you'll have to run the command make iosBuild. This'll first compile the source file, then generate an .app for it, install it on the currently opened iOS simulator and launch it with a console terminal.

Other noteworthy things to mention

If you want to set the icon, you have to either run make iosBuild ICON=<filename>.png, or make generateApp ICON=<filename>.png to only generate the app with the icon.

If you only want to install or launch the app, then you can use the command make iosInstall and make iosLaunch respectively.

How to create your own Silicon functions

If Silicon does not include a function from Cocoa that you need, you'll have to either create an issue on the github repo asking for the function or try to create your own function.

(These steps don't have to be done in order per se)\

First, make sure the class-type is defined

On line ~127 there is a bunch of typedefs for class-types\
If you can't find your class type simply add it to appropriate somewhere on the list  

eg. `NSWindow` becomes `typedef void NSWindow;`

Next, declare the function (and place it in a proper location in the file)\

`SICDEF [return-type] [class]_([object (if needed)], [args]);`\

```c
ex.
[window setFrame:(frame) display:(true) animate:(true)];

becomes 
void NSWindow_setFrameAndDisplay(NSWindow* window, NSRect frame, bool display, bool animate) 

[NSFont fontWithName:(str) size:(fontSize)];

becomes
NSFont* NSFont_init(const char* fontName, CGFloat fontSize);
```

Then, you must define any objective c classes and function selectors\

If your function is init'ing an object from a class, you may also need to define the class\
In which case, first check if the class is already defined, you can do this by checking the enum on line ~1239\

It will be in all caps in this format (NS_[CLASS]_CODE), eg. NSWindow becomes `NS_WINDOW_CODE`\

If it's not defined, find a proper place to put it in the enum\
Then go to the `si_initNS` function where you will define the class in the `SI_NS_CLASSES` array,\
if the `SI_NS_CLASSES` array is too small, raise it by 1\
eg. `void* SI_NS_CLASSES[36] = {NULL};` to `void* SI_NS_CLASSES[37] = {NULL};`\
Then find a proper place in the function to define the class and define it like this\
`SI_NS_CLASSES[(CLASS ENUM)] = objc_getClass("[CLASS NAME]");`

for example,
```c
SI_NS_CLASSES[NS_WINDOW_CODE] = obj_getClass("NSWindow");
```

Now, you define the function selectors

First, check if the function is already defined, you can do this by checking the enum on line ~1239\

It will be in all caps in this format (NS_[CLASS_NAME]_[FUNCTION_NAME]_CODE)\
eg. NSWindow_makeMainWindow becomes `NS_WINDOW_MAKE_MAIN_WINDOW_CODE`\

If it's not defined, find a proper place to put it in the enum\
Then go to the `si_initNS` function where you will define the class in the `SI_NS_FUNCTIONS` array,\
if the `SI_NS_FUNCTIONS` array is too small, raise it by 1\
eg. `void* SI_NS_FUNCTIONS[232];` to `void* SI_NS_CLASSES[233];`\
Then find a proper place in the function to define the class and define it like this\
`SI_NS_FUNCTIONS[(CLASS ENUM)] = objc_getClass("[FUNCTION NAME]");`

for example,
```c
SI_NS_FUNCTIONS[NS_WINDOW_MAKE_MAIN_WINDOW_CODE] = obj_getClass("makeMainWindow");
```

If your function has args, the class name (for objc_getClass) must include them\
If it's only one arg, you just need to add `:` at the end, if it's more than one,
you add one `:` then a `arg_name:` for each arg after

eg.
```c
NSWindow_setFrameAndDisplay(NSWindow* window, NSRect frame, bool display, bool animate);

becomes

SI_NS_FUNCTIONS[NS_WINDOW_SET_FRAME_AND_DISPLAY_CODE] = sel_getUid("setFrame:display:animate:");    
```

Check the Cocoa [documentation](https://developer.apple.com/documentation/) for more information

Finally, it's time to define the actual function

Simply find a good spot to define the function under the `#ifdef SILICON_IMPLEMENTATION` line\

Here is a quick example for `makeMainWindow`\
First, define `void* func` as being the function selector you want to use\
`void* func = SI_NS_FUNCTIONS[NS_WINDOW_MAKE_MAIN_WINDOW_CODE];`\
Next, use the proper `objc_msgSend` depending on the function's input and return type\ 
you may have to cast it yourself if none is avaliable, I'd suggest you check out functions which do this first.\
For `makeMainWindow`, we can use `objc_msgSend_void`

```c
void NSWindow_makeMainWindow(NSWindow* window) {
    void* func = SI_NS_FUNCTIONS[NS_WINDOW_MAKE_MAIN_WINDOW_CODE];
    objc_msgSend_void(window, func);
}
```

You may also need to convert NSArray to siArray (or vice versa), or NSString to const char* (or vice versa)\
In such cases I would suggest you refference other functions that do this

When doing a `_init` function, you may need to do an allocation for the class.\
Here is an example of that

```c
NSButton* NSButton_initWithFrame(NSRect frameRect) {
    void* func = SI_NS_FUNCTIONS[NS_BUTTON_INIT_WITH_FRAME_CODE];
    return objc_msgSend_id_rect(NSAlloc(SI_NS_CLASSES[NS_BUTTON_CODE]), func, frameRect);
}
```

Again, check the Cocoa [documentation](https://developer.apple.com/documentation/) for more information\
I would also suggest looking at Objective C example code to see if you need to use Alloc (or something else) or not

Examples

To compile and run all of the examples in a row, you can use make runExamples to test out everything at once.

  • menu.c - shows how to create menu bars in OS X.
  • button.c - shows how to create and utilize buttons using the Cocoa API.
  • checkbox.c - similar to the previous example from above, however instead they're checkboxes instead of regular buttons.
  • combobox.c - shows an example on how to utilize the NSComboBox class.
  • trackbar.c - shows how to create & utilize a track bar and progress bar.
  • opengl.c - shows how to setup an OpenGL environment with an event loop.
  • print.c - shows how to enable print debugging on iOS.

Documentation

Prerequisites

[todo]

Class shenanigans

[todo]

General tips

[todo]

Credits

General

  • hidefromkgb's 'mac_load' repository - the backend for some of the important parts of Silicon (such as defining Objective-C types and functions).
  • Apple - all of the headers from include/Silicon/headers have been directly copied and modified to not have any Objective-C shenanigans in them for them to be compiled in C.
  • EimaMei - original creator of Silicon.
  • Colleague Riley - creator of the original single-header version of Silicon (Silicon.h) and co-author of Silicon.

The example sources

All of the repositories that the examples were taken from and eithered completely ported to Silicon or modified heavilly:

silicon's People

Contributors

colleagueriley avatar eimamei avatar

Stargazers

Mateusz Karcz avatar Prabhu Gopal avatar qqap avatar Jeffrey H. Johnson avatar Vu Le avatar  avatar  avatar  avatar Alexandru-Mihai Maftei avatar Milan Nikolic avatar Pieter Valkema avatar  avatar João Penteado avatar Kyle Parisi avatar matias avatar  avatar Bocke avatar  avatar

Watchers

 avatar  avatar  avatar

silicon's Issues

Apple M2 + Sonoma: Save-file example crashes.

Hello.

save-file example crashes running under lldb after compiling with clang. lldb trace shown below.

Any thoughts?


Current executable set to '/Users/jevans/src/osx/Silicon-h/save-file' (arm64).
(lldb) r
Process 17950 launched: '/Users/jevans/src/osx/Silicon-h/save-file' (arm64)
2023-11-27 16:44:58.359539+0000 save-file[17950:2642947] [General] -[NSWindow OnButtonClick]: unrecognized selector sent to instance 0x129709fb0
2023-11-27 16:44:58.362152+0000 save-file[17950:2642947] [General] (
	0   CoreFoundation                      0x000000018ddce800 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000018d8c5eb4 objc_exception_throw + 60
	2   CoreFoundation                      0x000000018de803bc -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x000000018dd38a84 ___forwarding___ + 1572
	4   CoreFoundation                      0x000000018dd383a0 _CF_forwarding_prep_0 + 96
	5   AppKit                              0x00000001916d8464 -[NSApplication(NSResponder) sendAction:to:from:] + 460
	6   AppKit                              0x00000001916d8268 -[NSControl sendAction:to:] + 72
	7   AppKit                              0x00000001916d81ac __26-[NSCell _sendActionFrom:]_block_invoke + 100
	8   AppKit                              0x00000001916d80d4 -[NSCell _sendActionFrom:] + 204
	9   AppKit                              0x00000001916d7ff8 -[NSButtonCell _sendActionFrom:] + 88
	10  AppKit                              0x00000001916d5628 NSControlTrackMouse + 1480
	11  AppKit                              0x00000001916d5034 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 144
	12  AppKit                              0x00000001916d4eec -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 488
	13  AppKit                              0x00000001916d43c0 -[NSControl mouseDown:] + 448
	14  AppKit                              0x00000001916d318c -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3472
	15  AppKit                              0x000000019165e690 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 364
	16  AppKit                              0x000000019165e350 -[NSWindow(NSEventRouting) sendEvent:] + 284
	17  AppKit                              0x0000000191d07f30 -[NSApplication(NSEventRouting) sendEvent:] + 1604
	18  AppKit                              0x000000019195a110 -[NSApplication _handleEvent:] + 60
	19  AppKit                              0x0000000191526124 -[NSApplication run] + 512
	20  save-file                           0x000000010000197c NSApplication_run + 36
	21  save-file                           0x0000000100001330 main + 676
	22  dyld                                0x000000018d9010e0 start + 2360
)


'examples/general mac-load.c' has stopped working

The macload.c example doesn't draw a blue polygon anymore despite the example staying relatively unchanged for a while. It seems that the 'onRect' function doesn't even get called once, so the problem might be related to the conversion of C functions into SELs.

Good idea but cannot build

Any thoughts on this? It's a good idea and building on the previous work gets a big tick.

I'd like to see if up and running. N.B. Only tried building for MacOSX.

Thanks for listening.

Sonoma 14.1.1
XCode 15.0.1
% clang --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Running make runExamples 2>&1 | tee out.log results in a good number of errors, as shown below:

clang -O2 -std=c99 -I"include" -Wno-deprecated-declarations  source/mac/NSGeometry.m -c -o build/NSGeometry.o
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:33:
include/Silicon/mac/types.h:56:15: error: typedef redefinition with different types ('char *' vs 'NSString *')
typedef char* NSNotificationName; /* Note: originally this was NSString* */
              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSNotification.h:7:19: note: previous definition is here
typedef NSString *NSNotificationName NS_TYPED_EXTENSIBLE_ENUM;
                  ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:33:
include/Silicon/mac/types.h:59:17: error: redefinition of 'NSAutoreleasePool' as different kind of symbol
mac_type_define(NSAutoreleasePool);
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSAutoreleasePool.h:10:12: note: previous definition is here
@interface NSAutoreleasePool : NSObject {
           ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:33:
include/Silicon/mac/types.h:61:17: error: redefinition of 'NSView' as different kind of symbol
mac_type_define(NSView);
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Headers/PDEPluginInterface.h:28:8: note: previous definition is here
@class NSView;
       ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:33:
include/Silicon/mac/types.h:64:17: error: redefinition of 'NSNotification' as different kind of symbol
mac_type_define(NSNotification);
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSNotificationQueue.h:8:8: note: previous definition is here
@class NSNotification, NSNotificationCenter, NSArray<ObjectType>, NSString;
       ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:33:
include/Silicon/mac/types.h:68:17: error: redefinition of 'NSFileManager' as different kind of symbol
mac_type_define(NSFileManager);
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSFileManager.h:96:12: note: previous definition is here
@interface NSFileManager : NSObject
           ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:33:
include/Silicon/mac/types.h:69:17: error: redefinition of 'NSProcessInfo' as different kind of symbol
mac_type_define(NSProcessInfo);
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSProcessInfo.h:29:12: note: previous definition is here
@interface NSProcessInfo : NSObject {
           ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:33:
include/Silicon/mac/types.h:76:17: error: redefinition of 'NSImage' as different kind of symbol
mac_type_define(NSImage);
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:8:112: note: previous definition is here
@class NSString, NSDictionary<KeyType, ObjectType>, NSArray<ObjectType>, NSDateComponents, NSDate, NSTimeZone, NSImage, NSAttributedString, NSUserNotificationAction;
                                                                                                               ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:14:29: error: redefinition of 'NSSearchPathDirectory'
typedef NS_ENUM(NSUInteger, NSSearchPathDirectory) {
                            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:61:29: note: previous definition is here
typedef NS_ENUM(NSUInteger, NSSearchPathDirectory) {
                            ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:15:5: error: redefinition of enumerator 'NSApplicationDirectory'
    NSApplicationDirectory = 1,             // supported applications (Applications)
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:62:5: note: previous definition is here
    NSApplicationDirectory = 1,             // supported applications (Applications)
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:16:5: error: redefinition of enumerator 'NSDemoApplicationDirectory'
    NSDemoApplicationDirectory,             // unsupported applications, demonstration versions (Demos)
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:63:5: note: previous definition is here
    NSDemoApplicationDirectory,             // unsupported applications, demonstration versions (Demos)
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:17:5: error: redefinition of enumerator 'NSDeveloperApplicationDirectory'
    NSDeveloperApplicationDirectory,        // developer applications (Developer/Applications). DEPRECATED - there is no one single Developer directory.
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:64:5: note: previous definition is here
    NSDeveloperApplicationDirectory,        // developer applications (Developer/Applications). DEPRECATED - there is no one single Developer directory.
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:18:5: error: redefinition of enumerator 'NSAdminApplicationDirectory'
    NSAdminApplicationDirectory,            // system and network administration applications (Administration)
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:65:5: note: previous definition is here
    NSAdminApplicationDirectory,            // system and network administration applications (Administration)
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:19:5: error: redefinition of enumerator 'NSLibraryDirectory'
    NSLibraryDirectory,                     // various documentation, support, and configuration files, resources (Library)
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:66:5: note: previous definition is here
    NSLibraryDirectory,                     // various documentation, support, and configuration files, resources (Library)
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:20:5: error: redefinition of enumerator 'NSDeveloperDirectory'
    NSDeveloperDirectory,                   // developer resources (Developer) DEPRECATED - there is no one single Developer directory.
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:67:5: note: previous definition is here
    NSDeveloperDirectory,                   // developer resources (Developer) DEPRECATED - there is no one single Developer directory.
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:21:5: error: redefinition of enumerator 'NSUserDirectory'
    NSUserDirectory,                        // user home directories (Users)
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:68:5: note: previous definition is here
    NSUserDirectory,                        // user home directories (Users)
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:22:5: error: redefinition of enumerator 'NSDocumentationDirectory'
    NSDocumentationDirectory,               // documentation (Documentation)
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:69:5: note: previous definition is here
    NSDocumentationDirectory,               // documentation (Documentation)
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:23:5: error: redefinition of enumerator 'NSDocumentDirectory'
    NSDocumentDirectory,                    // documents (Documents)
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:70:5: note: previous definition is here
    NSDocumentDirectory,                    // documents (Documents)
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:24:5: error: redefinition of enumerator 'NSCoreServiceDirectory'
    NSCoreServiceDirectory,                 // location of CoreServices directory (System/Library/CoreServices)
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:71:5: note: previous definition is here
    NSCoreServiceDirectory,                 // location of CoreServices directory (System/Library/CoreServices)
    ^
In file included from source/mac/NSGeometry.m:9:
In file included from include/Silicon/silicon.h:53:
In file included from include/Silicon/mac/silicon.h:34:
In file included from include/Silicon/mac/enums.h:40:
include/Silicon/mac/headers/NSPathUtilities.h:25:5: error: redefinition of enumerator 'NSAutosavedInformationDirectory'
    NSAutosavedInformationDirectory API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0)) = 11,   // location of autosaved documents (Documents/Autosaved)
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSPathUtilities.h:72:5: note: previous definition is here
    NSAutosavedInformationDirectory API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0)) = 11,   // location of autosaved documents (Documents/Autosaved)
    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [build/NSGeometry.o] Error 1

Some suggestions.

Would be more than happy to help out with these.

  1. Add a section to the readme which details how to extend the silicon.h API? i.e. how to add C analogues of existing Obj-C APIs?
  2. Clarify what needs to be tracked in terms of object ownership (autorelease pools etc)
  3. Maybe add a link to the Apple metal-cpp implementation which contains some very useful C++ classes for managing stock ObjC types. (https://developer.apple.com/metal/cpp/)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.