-
-
Save jish/24734d381fb9a27525b9f91bdfa21c77 to your computer and use it in GitHub Desktop.
GameUpdateAndRender in a separate file causes issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
mkdir -p build | |
gcc -framework Cocoa \ | |
-x objective-c \ | |
code/osx_handmade.mm \ | |
-o build/handmade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In file included from code/osx_handmade.mm:3: | |
code/handmade.h:3:15: warning: function 'GameUpdateAndRender' has internal linkage but is not | |
defined [-Wundefined-internal] | |
internal void GameUpdateAndRender(); | |
^ | |
code/osx_handmade.mm:63:3: note: used here | |
GameUpdateAndRender(); | |
^ | |
1 warning generated. | |
Undefined symbols for architecture x86_64: | |
"_GameUpdateAndRender", referenced from: | |
_main in osx_handmade-4f9411.o | |
ld: symbol(s) not found for architecture x86_64 | |
clang: error: linker command failed with exit code 1 (use -v to see invocation) | |
make: *** [osx] Error 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "handmade.h" | |
internal void GameUpdateAndRender() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define internal static | |
internal void GameUpdateAndRender(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Cocoa/Cocoa.h> | |
#include "handmade.h" | |
void OSXInitNSApplication(void) | |
{ | |
NSApplication *app = [NSApplication sharedApplication]; | |
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; | |
} | |
void OSXCreateMainMenu() { | |
NSString* appName = @"Handmade Hero"; | |
NSMenu* menubar = [NSMenu new]; | |
NSMenuItem* appMenuItem = [NSMenuItem new]; | |
[menubar addItem:appMenuItem]; | |
[NSApp setMainMenu:menubar]; | |
NSMenu* appMenu = [NSMenu new]; | |
NSString* fullScreenTitle = @"Toggle Full Screen"; | |
NSMenuItem* fullScreenItem = [[NSMenuItem alloc] | |
initWithTitle:fullScreenTitle | |
action:@selector(toggleFullScreen:) | |
keyEquivalent:@"f"]; | |
[appMenu addItem:fullScreenItem]; | |
NSString* quitTitle = [@"Quit " stringByAppendingString:appName]; | |
NSMenuItem* quitMenuItem = [[NSMenuItem alloc] | |
initWithTitle:quitTitle | |
action:@selector(terminate:) | |
keyEquivalent:@"q"]; | |
[appMenu addItem:quitMenuItem]; | |
[appMenuItem setSubmenu:appMenu]; | |
} | |
void OSXCreateWindow() { | |
NSString* appName = @"Handmade Hero"; | |
NSRect initialFrame = NSMakeRect(0, 0, 640, 480); | |
NSWindow* window = [[NSWindow alloc] initWithContentRect:initialFrame | |
styleMask:NSTitledWindowMask | |
backing:NSBackingStoreBuffered | |
defer:NO]; | |
[window cascadeTopLeftFromPoint:NSMakePoint(20,20)]; | |
[window setBackgroundColor:NSColor.blackColor]; | |
[window setTitle:appName]; | |
[window makeKeyAndOrderFront:nil]; | |
[NSApp activateIgnoringOtherApps:YES]; | |
[NSApp run]; | |
} | |
int main (int argc, char const *argv[]) | |
{ | |
OSXInitNSApplication(); | |
OSXCreateMainMenu(); | |
OSXCreateWindow(); | |
// Commenting out this call, allows the program to compile | |
// and run again. | |
GameUpdateAndRender(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment