Application Error ?

I added // for the #include <Cocoa/Cocoa.h> to start programming the interface of NSApplication and receive the error specified in the code I just typed here :

//

//  main.m

//  Hostile

//

//  Created by Besleaga Alexandru Marian on 10/20/21.

//

//  #include <Cocoa/Cocoa.h>



int main(int argc, const char * argv[]) {

    @autoreleasepool {

        // Setup code that might create autoreleased objects goes here.

    }

    return NSApplicationMain(argc, argv);

}

There error message is the following :

Implicit declaration of function 'NSApplicationMain' is invalid in C99

I added // for the #include <Cocoa/Cocoa.h> to start programming the interface of NSApplication

Why did you do that??? to start programming the interface of NSApplication does not make sense.

In modern C (as you can find C99, it is not too modern), you need to import/include the prototype definitions of all functions, before using them. You need to import the prototype definition of NSApplicationMain, if you want to use it. Which is included in <Cocoa/Cocoa.h>.

Is is mandatory to import it or I can program it myself ?

Kind Regards

//

//  main.m

//  Hostile

//

//  Created by Besleaga Alexandru Marian on 10/20/21.

//

//  #import <Cocoa/Cocoa.h>



@interface NSObject



@end



@interface NSResponder : NSObject



@end



@interface NSEvent : NSObject



@end



@interface NSView : NSResponder



@end



@interface NSWindow : NSResponder



@end



@interface NSApplication : NSResponder



@property(class, readonly, strong) __kindof NSApplication *sharedApplication;



- (void)run;



- (void)stop:(id)sender;



- (void)terminate:(id)sender;



- (void)sendEvent:(NSEvent *)event;



@end



typedef int *NSApp;



int NSApplicationMain(int argc, const char * _Nonnull *argv);



int main(int argc, const char * argv[]) {

    @autoreleasepool {

        // Setup code that might create autoreleased objects goes here.

    }

    return NSApplicationMain(argc, argv);

}

My questions is the following : If I have a Main file, I want to remove the Main file and see the NSWindow the Window on the display from the code that I'm programming. Where should I search in the documentation to solve these issue ?

If I have a Main file, I want to remove the Main file

You cannot remove the Main file, so your question does not make sense.

see the NSWindow the Window on the display from the code that I'm programming.

Can you explain what you mean by this?

Where should I search in the documentation to solve these issue ?

I do not understand what your question is. What are these issue?

The issue is the main file that shows the window, do you know how to program the window or you just follow the program ?

The issue is the main file that shows the window

What in the main file is the problem?????????? Please clarify.

If you want to learn app programming, keep the main file as in the app template. Never modify it.

If you are planning to learn something else, please clarify what you want to achieve.

Application Error ?
 
 
Q