|
-
March 1st, 2008, 07:45 PM
#1
char vs CHAR
Hi guys,
char is a base language type,
while CHAR is a windows type declare in windows.h as follows:
I can't understand why whould I need it??
if CHAR equel to char why use it, and why windows.h bother creating a new type for it ??
-
March 1st, 2008, 09:13 PM
#2
Re: char vs CHAR
windows.h does things like that all the time. Smile and nod.
I'm sure someone thought at one time that it might be a good idea, and ever since then that's been Just The Way It Is.
Also, using such typedefs would theoretically allow code to survive changes to the underlying language (such as how large a char is), simply be altering the typedef. However, since Microsoft wrote the most common Windows compiler, and has no interest in porting Windows to other systems, this seems like needless effort.
Last edited by Lindley; March 1st, 2008 at 09:16 PM.
-
March 1st, 2008, 09:36 PM
#3
Re: char vs CHAR
lol, i've never really understood it either seeing as if you use CHAR the ide doesn't highlight it so theres only a disadvantage, but i guess because it's consistent with all the caps with all the other typedefs
-
March 2nd, 2008, 06:51 PM
#4
Re: char vs CHAR
lol, I noded and I have a huge smile on my face (nice message Lindley), but I can't let it go, I must find a reason why to use CHAR over char, I tried to find an answer on google for the last 2 hours with Zero results.
I must find one, It just doesn't make any sense, but there must be one otherwise it woulden't go into windows.h.....
Please find me a reason.......
-
March 2nd, 2008, 07:54 PM
#5
Re: char vs CHAR
 Originally Posted by Salvadoravi
I must find a reason why to use CHAR over char, I tried to find an answer on google for the last 2 hours with Zero results.
Those macros go back more than 18 years. They were used in the original Windows 1.0 API, and were brought forward to make sure that existing code using them did not break. That is why they're still around today.
It was just the Microsoft's engineers idea to make sure that a Windows API programmer never have to specify a 'C' type explicitly when using API functions, that's all. Look at LONG, BOOL, UCHAR, etc.
Regards,
Paul McKenzie
-
March 3rd, 2008, 05:50 AM
#6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|