digitalmars.D - Help with Compiler Error
- Brad Anderson (19/19) May 22 2004 I'm getting an error from the compiler that I don't understand, and woul...
- Mike Swieton (10/17) May 22 2004 I'm betting that the error is that DefMDIChildProc is not a static metho...
- Brad Anderson (3/26) May 22 2004 Making DefMDIChildProc() static in os.d didn't seem to help :(
- Brad Anderson (5/38) May 23 2004 But making the method static AND making the class static did work.
- Mike Swieton (8/15) May 23 2004 Ok, I'll bite: what does static mean in the context of a class?
- Brad Anderson (14/35) May 24 2004 It didn't work yesterday when I only made the method static, but things
I'm getting an error from the compiler that I don't understand, and would appreciate any help. The error is: 'this' is required, but OS is not a base class of Decorations The error is on the return OS.DefMDIChildProc() line. decorations.d: ---------------------------- public class Decorations : Canvas { int callWindowProc (int msg, int wParam, int lParam) { return OS.DefMDIChildProc (handle, msg, wParam, lParam); } } os.d ---------------------------- class OS { int DefMDIChildProc (int hWnd, int Msg, int wParam, int lParam) { if (IsUnicode) return DefMDIChildProcW (hWnd, Msg, wParam, lParam); return DefMDIChildProcA (hWnd, Msg, wParam, lParam); } }
May 22 2004
On Sun, 23 May 2004 00:30:24 -0500, Brad Anderson wrote:I'm getting an error from the compiler that I don't understand, and would appreciate any help. The error is: 'this' is required, but OS is not a base class of Decorations The error is on the return OS.DefMDIChildProc() line. <SNIP>I'm betting that the error is that DefMDIChildProc is not a static method, and you're calling it in a static context. That is a particularly bad error message, though. Mike Swieton __ I believe you should live each day as if it is your last, which is why I don't have any clean laundry because, come on, who wants to wash clothes on the last day of their life? - Anonymous kid, aged 15 (but may as well be me!)
May 22 2004
Making DefMDIChildProc() static in os.d didn't seem to help :( BA Mike Swieton wrote:On Sun, 23 May 2004 00:30:24 -0500, Brad Anderson wrote:I'm getting an error from the compiler that I don't understand, and would appreciate any help. The error is: 'this' is required, but OS is not a base class of Decorations The error is on the return OS.DefMDIChildProc() line. <SNIP>I'm betting that the error is that DefMDIChildProc is not a static method, and you're calling it in a static context. That is a particularly bad error message, though. Mike Swieton __ I believe you should live each day as if it is your last, which is why I don't have any clean laundry because, come on, who wants to wash clothes on the last day of their life? - Anonymous kid, aged 15 (but may as well be me!)
May 22 2004
But making the method static AND making the class static did work. Maybe we can get a better error message from the compiler. Thanks, Mike. BA Brad Anderson wrote:Making DefMDIChildProc() static in os.d didn't seem to help :( BA Mike Swieton wrote:On Sun, 23 May 2004 00:30:24 -0500, Brad Anderson wrote:I'm getting an error from the compiler that I don't understand, and would appreciate any help. The error is: 'this' is required, but OS is not a base class of Decorations The error is on the return OS.DefMDIChildProc() line. <SNIP>I'm betting that the error is that DefMDIChildProc is not a static method, and you're calling it in a static context. That is a particularly bad error message, though. Mike Swieton __ I believe you should live each day as if it is your last, which is why I don't have any clean laundry because, come on, who wants to wash clothes on the last day of their life? - Anonymous kid, aged 15 (but may as well be me!)
May 23 2004
On Sun, 23 May 2004 23:36:40 -0500, Brad Anderson wrote:But making the method static AND making the class static did work. Maybe we can get a better error message from the compiler. Thanks, Mike. BAOk, I'll bite: what does static mean in the context of a class? Mike Swieton __ If I need a screwdriver and I select a hammer, I probably won't get anywhere and will eventually realize my error. The problem with software is that we are able to turn a hammer into a screwdriver. - Laurent Bossavit
May 23 2004
It didn't work yesterday when I only made the method static, but things began to work as I did this: public static class OS { static int DefMDIChildProc() { ... } } It didn't make much sense to me, but I tried it. The spec says that static is only used on functions and data. But I couldn't get the code to work unless I added it up by class. Now, of course, after your post questioning this, I took out the static before class and it works fine. So I must have had something else wrong. BA Mike Swieton wrote:On Sun, 23 May 2004 23:36:40 -0500, Brad Anderson wrote:But making the method static AND making the class static did work. Maybe we can get a better error message from the compiler. Thanks, Mike. BAOk, I'll bite: what does static mean in the context of a class? Mike Swieton __ If I need a screwdriver and I select a hammer, I probably won't get anywhere and will eventually realize my error. The problem with software is that we are able to turn a hammer into a screwdriver. - Laurent Bossavit
May 24 2004