2

I'm porting some ObjC/FoundationKit code to Windows using WinObjC. Impressed so far (well done MS!). Can I use Win32 APIs in the project? When I try to simply include "windows.h" (in a .m file) I then get errors which seem to suggest ObjC compilation has been disabled for the rest of the file (unexpected @ in program). Any ideas? I'm guessing it's something simple.

It's been 12+ years since I've done any Win32 work so maybe windows.h isn't even relevant any more?

Thanks!

December
  • 584
  • 5
  • 10
  • Are you sure it's disabling Objective-C? That is, can you do, say, `@class ClassThatDoesNotEixst;` before including `windows.h` and it will work? And no, `windows.h` is still relevant to Windows *desktop app* programming, at least. – andlabs Aug 22 '15 at 20:20
  • Also how are you building your project, from within Visual Studio or via command-line? If the former, what type of project is this? – andlabs Aug 22 '15 at 20:34
  • Thanks for your reply. I'm using VS. The problem can be reproduced using the HelloUI sample app. Just include after the #import . – December Aug 23 '15 at 09:21
  • That example seems to be for an iOS app, not for a Windows program. I wonder if you can invoke the compiler directly to build Windows software... – andlabs Aug 23 '15 at 15:29
  • According to MS's wiki there is support for calling Windows APIs directly: https://github.com/Microsoft/WinObjC/wiki (scroll down about half way). – December Aug 23 '15 at 22:23
  • Okay, so it is possible. That wiki page describes writing programs for the Windows Runtime and Universal Windows Platform, which isn't older windows.h desktop programming. But I don't see why it wouldn't be possible... What error do you get if you have `@class xxx;` before `#include `? I'm wondering if there might be something else getting in the way... I can personally try myself at a later date (would need to set up Windows 10 first). – andlabs Aug 23 '15 at 22:46
  • @class before windows.h works fine. After you've included it though you'll get errors when the compiler encounters anything ObjC related. I've encountered so many issues with the IDE/SDK though I'm happy to wait till the tools are a little more mature before I dive back into this. – December Aug 25 '15 at 08:27

0 Answers0