Cocoa->Carbon (NSView to WindowRef)


I am porting a Windows app to MacOSX and have some code written in Cocoa that has an NSView that I need to attach an OpenGL rendering context to (via the aglFuncs...(...)). I am interfacing with a large, existing C++ code base so re-engineering everything for Cocoa is not an option, neither is using the "Cocoa friendly" OpenGL calls. What I am trying is:

NSView * pNSView = pSomeKnownNSView;
NSWindow * pNSWindow = [pNSView window];
WindowRef refWindow = (WindowRef)[pNSWindow windowRef]
However, I am getting the compile warning:
Warning: no "-windowRef" method found

2 questions... 1) Am I taking the correct path for what I want to do? 2) According to Apple's Cocoa reference docs (, the windowRef function exists (and I did check the NSWindow.h in the AppKit Framework)... any ideas why I am getting this and how I can remove the warning?

One nit picking comment... don't use "NS" in your variable names... it's not good programming style.... NS just exists because Cocoa doesn't have namespaces (and it helps to identify who made the class). If NS wasn't used, then you could never make your own classes called "Window" or "String" or whatever... :)