简体   繁体   中英

cocoa framework in carbon class

I am writing Contextual Menu Plugins for Leopard OS and referring SampleCMPlugIn . its working fine. Now i want to call cocoa function from this plugin but when i am adding cocoa framework into my project and including into source file i am getting 10874 errors like.

/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:126:0 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:126: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token


/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:127:0 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:127: error: expected ')' before '*' token


/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:129:0 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:129: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

EDIT:

when i change my source code file extension from .c to .mm as suggested by Michael Dautermann , i got 5 errors:

/Users/path/SampleCMPlugIn.mm:826:0 /Users/path/SampleCMPlugIn.mm:826: error: invalid conversion from 'const void*' to 'const __CFUUID*'


/Users/path/SampleCMPlugIn.mm:1228:0 /Users/path/SampleCMPlugIn.mm:1228: error: jump to label 'SampleSubMenu_Create_Complete_fail'


/Users/path/SampleCMPlugIn.mm:1140:0 /Users/path/SampleCMPlugIn.mm:1140: error:   from here


/Users/path/SampleCMPlugIn.mm:1143:0 /Users/path/SampleCMPlugIn.mm:1143: error:   crosses initialization of 'int disableMainMenu'


/Users/path/SampleCMPlugIn.mm:1142:0 /Users/path/SampleCMPlugIn.mm:1142: error:   crosses initialization of 'int count'

can anyone please help me out?

Sure. Check out the yellow box that appears when you open that legacy SampleCMPlugin page that you mentioned:

Important: The information in this document is obsolete and should not be used for new development . Links to downloads and other resources may no longer be valid.

Carbon is deprecated and more importantly, the code you're writing is likely to not be compatible with 64-bit OS'es (in which case it won't get loaded by the Finder).

A good alternative would be to use Services menus .

I also just Googled up this ad for a product called Abracode Shortcuts which appears to be a free thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM