flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Remove C++ type checking?

Author
Thread Post new topic Reply to topic
joz



Joined: 20 Jan 2008
Posts: 2
joz
Is there a way to turn off type-checking in a C++ program? It's really annoying to have to use 40 different types of DWORD.

This code :
Code:
DialogBoxParam(hInstance,IDD_DIALOG1,0,&DialogProc,0);    

Generates an error, not a warning.

This code works :
Code:
DialogBoxParam(hInstance,(LPCSTR)IDD_DIALOG1,0,&DialogProc,0);    


You see, here, IDD_DIALOG = 1001, but I have to use (LPCSTR) to make this call work. I'd like to have more freedom over my datatypes.
Is it possible ?
Post 20 Jan 2008, 17:37
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
impossible. proper way is to define IDD_DIALOG as LPCSTR directly:
Code:
#define IDD_DIALOG1 (LPCSTR)1001
    
Post 20 Jan 2008, 20:04
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
dap



Joined: 01 Dec 2007
Posts: 61
Location: Belgium
dap
Try to use this : http://msdn2.microsoft.com/en-us/library/ms648029.aspx

[Edit]

In C it's possible to remove the type checking, just don't give any prototype :

Code:
void f ();


int main (void)
{
   f(1), f(2.0), f((void*)NULL);
   return 0;
}


void f ()
{
   
}
    


I guess there is something similar in C++ but if so I don't recommend you to use it.
Post 20 Jan 2008, 20:40
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Find a different programming language if you aren't going to use the programming language properly.

Yes, using Win32 API is a bit of a pain in C++, because the PlatformSDK was designed badly. Can't really blame Microsoft for that, though, since it was started back in the early days, and was made for C not C++.
Post 20 Jan 2008, 21:00
View user's profile Send private message Visit poster's website Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 535
drhowarddrfine
Quote:
using Win32 API is a bit of a pain in C++
the PlatformSDK was designed badly.
Can't really blame Microsoft for that
So who do we blame for that?
Post 20 Jan 2008, 23:45
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
drhowarddrfine wrote:
Quote:
using Win32 API is a bit of a pain in C++
the PlatformSDK was designed badly.
Can't really blame Microsoft for that
So who do we blame for that?


We can blame users that insist on heavy backwards compatibility.

The PlatformSDK includes could be rewritten to be (a lot) more C++ friendly (while still being binary compatible with windows), but it would be a massive undertaking, and all windows apps would need large rewrites.

Less radical changes could be done which would still be very nice, but would probably end up breaking a few apps nonetheless... and Microsoft always gets a lot of flak whenever a tiny little thing breaks, even if it's because some developer used undocumented calls/whatever.

Remember that the the windows includes were started before C++ became popular. Heck, I've considered moving all UI glue (which is where the PSDK is most annoying, imho) to .c files, simply to reduce casting hell.

_________________
Image - carpe noctem
Post 21 Jan 2008, 01:11
View user's profile Send private message Visit poster's website Reply with quote
joz



Joined: 20 Jan 2008
Posts: 2
joz
With Visual C++ 2003, if you go in the options and change compiler type from C++ to C, you'll get a warning instead of an error. That's much better, why isn't it this way with C++ Laughing

I can't believe this. They believe people can handle pointers in C++ but not type checking? This is madness! (Don't give me the Sparta joke, I'll see it coming Laughing ).
Post 21 Jan 2008, 05:25
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
If you change compiler type from C++ to C, you are using C and not C++, and you really should use ".c" instead of ".cpp" file extension, which will do this automatically.

Type checking in C++ is nice and catches a good deal of errors, but is annoying when you deal with legacy C code. For "real" C++ code, you hardly ever need casts.
Post 21 Jan 2008, 11:19
View user's profile Send private message Visit poster's website Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
imho, proper way is

DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),0,DialogProc,0);
Post 22 Jan 2008, 10:27
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
sorry, quite possible... never been to much into API stuff.
Post 22 Jan 2008, 10:31
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.